CS代写:java代写 case write a program代码代写北美代写

Part 1:

You are a programming intern at the student transfer counselor's office. Having heard you are taking CS 55, your boss has come to ask for your help with a task.

Students often come to ask her whether their GPA is good enough to transfer to some college to study some major and she has to look up the GPA requirements for a school and its majors in a spreadsheet to answer their question. She would like you to write a program that students can use themselves to get their answer. She is providing you with the spreadsheet data.

CS

Econ

English

UCLA

3.7

3.5

3.2

UCB

3.8

3.4

3.3

UCI

3.6

3.7

3.4

UCSD

3.5

3.3

3.0

You will write a program, TransferAdvisor.java, which asks the user for the school name, the major, and their GPA, and informs them whether their GPA is adequate for the school and major selected, or by how much they need to improve it. If a school or major is not in the spreadsheet, the user is informed. The school names and majors can be entered both as shown in the spreadsheet or in all lowercase letters. The “You need to improve your GPA by ### ...” message should have 2 decimals precision for the GPA regardless of the student GPA entered.

Below are a few runs of the program:

Enter the school name: UCLA Enter the major: CS

Enter your GPA: 3.457

You need to improve your GPA by 0.24 to transfer to UCLA to study CS

-----------------

Enter the school name: ucsd Enter the major: english Enter your GPA: 3.12

– To avoid a lot of duplication with the code dealing with the GPA comparison and printouts, write a method that takes in the school name, the major name, the required GPA for that major in that school and the student GPA, and prints out either the “You could transfer …” or the “You needto

improve your GPA by ...”.

– Avoid if/else if/... to match the school and the major. Switch/case makes the codecleaner.

Part 2:

Your boss has come to ask for your help with another task. She would like you to write a

simple program that encodes and decodes “secret messages” which she plans to demonstrate to elementary school students to kindle their interest in Computer Science.

The encoding/decoding scheme is very simple. Each letter is substituted by some other letter according to a given mapping as shown below.

For example, every 'a' becomes a 'k' when encoding a text, and every 'k' becomes an 'a' when decoding.

You will write a program, SecretMessage.java, which asks the user whether they would like to encode or decode a message, and then encodes or decodes the message using the mapping above.

Capital letters are mapped the same way as the lower case letters above, but remain capitalized.

For example, every 'A' becomes 'K' when encoding a text, and every 'K' becomes an 'A' whendecoding. Numbers and other characters are not encoded and remain the same. The program repeatedly asks the user for input until the userquits.

Below is one run of theprogram:

Enter 1 to encode, 2 to decode, 3 to quit: 1 Enter the text to encode:

Santa Monica College Spring 2014 Lktzk Jitbgk Gihhasa Luybts 2014

Enter 1 to encode, 2 to decode, 3 to quit: 1 Enter the text to encode:

programming is fun uyisykjjbts bl dqt

Enter 1 to encode, 2 to decode, 3 to quit: 2 Enter the text to decode:

Lktzk Jitbgk Gihhasa Luybts 2014 Santa Monica College Spring 2014

Enter 1 to encode, 2 to decode, 3 to quit: 3 Good bye

Hints:

Think about decomposing the problem into simpler problems. You will likely find it helpful to

write a few very simple methods first:

– isLowerCaseLetter takes a char and returns true if that letter is a lower case letter(between 'a' and 'z'). isUpperCaseLetter and isLetter should worksimilarly.

– toLowerCase takes an upper case letter and returns the same letter in lower case. Do notuse conditionals to implement this (if/else or switch). Instead, remember that a char is “a number” code. Print that number code for 'A', 'B', 'a', 'b' to see how it looks and come up with a very simple way to change an upper case letter to lower case. toUpperCase should worksimilarly.

– codeChar takes a char and a boolean flag. If the flag is true, it returns the encoded char according to the given mapping. If the flag is false, it returns the decoded char according to the given mapping. Do not use conditionals to do the mapping. Instead, notice that theletter 'a' is encoded to the first character of the given encoding map. The letter 'b' to thesecond,

and so on. For the decoding, you can write a decoding string by hand that you can use to map the encoded letters 'a' to 'z' to their decoded counterparts.

Given a String in Java you can use the charAt method to get the letter at a given position. For example:

String s = "example";

char first=s.charAt(0);// first is assigned'e'

char second=s.charAt(1);// second is assigned'x'

Notice that to get the character at the first position we pass the argument 0 to the charAt method and not 1.

– codeMessage takes a String and a boolean flag. If the flag is true, it prints the givenmessage encoded. If the flag is false, it prints the given message decoded. This method just calls the codeChar method for every character in the String and prints the character that codeChar returns. It is really short andsimple.

Given a String in Java you can use the length method to get the number of characters in that String. For example:

String s = "hello";

int len=s.length();// len is assigned5

Deliverables:

You should submit a zip file named project1_first_last.zip (where first and last are your first and last name) containing ONLY the 2 files below.