ITP 120 Final Exam Summer 2021
Part II. Programming Questions
Total Points – 100 Total Points Earned:______
1.
Calculating the total cost of a sandwich order
Problem Description:
Write a program in a class SandwichCounter that computes the cost of sandwiches sold at a food stand. Three kinds of sandwiches —cheese steak, chicken, and salad— are cost, respectively, $8.5, $7.5, and $7.0 per sandwich. Create an array of strings that holds the names of these sandwiches. Create another array that holds the cost of each corresponding sandwich. Your program should read the name of a sandwich and the quantity desired by a customer. Locate the sandwich in the name array and use that index to find the cost per purchase in the cost array. Compute and print the total cost of the sale.
Please submit the source code and bytecode.
2. Catch exception(s)
Problem Description:
Write a program that allows the user to compute the remainder after the division of two integer values. The remainder of x / y is x % y. Catch any exception thrown and allow the user to enter new values.
Please submit the source code and bytecode.
3. Baby Name Ranking
Problem Description:
The popularity ranking of baby names for year 2017 is provided. Each line contains a ranking, a boy’s name, and a girl’s name. Write a program that prompts the user to enter the gender, and followed by a name, and displays the ranking of the name for the year. Here is a sample run:
Enter the gender: M
Enter the name: Javier
Javier is ranked #231
Enter the gender: F
Enter the name: ABC
The name ABC is not ranked
Please submit the source code and bytecode.
4. Student Class
Problem Description:
Create a class "Student" that is the base class for students at a school. It should have attributes for the student’s name and age, the name of the student’s teacher, and a greeting. It should have appropriate accessor and mutator methods for each of the attributes.
Please submit the source code and bytecode.
5. Graduate and undergraduate students?
Problem Description:
Create two classes GraduateStudent and UndergradStudent that derived from "Student" class, as described in the previous exercise. The new classes should override the accessor method for the age, reporting the actual age plus 2. It also should override the accessor for the greeting, returning the student’s greeting concatenated with the words “I am a graduate student.” or "I am an undergraduate student." correspondingly.
Please submit the source code and bytecode.