Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

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...

1 answer below »

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.

Answered Same Day Aug 06, 2021 ITP120

Solution

Swapnil answered on Aug 06 2021
138 Votes
89220/1/SandwichCounter.java
89220/1/SandwichCounter.java
import java.util.Scanner;
public class SandwichCounter 
{
   public static void main(String[] args) 
   {
       String names[] = { "Cheese Steak", "Chicken", "Salad" };
       double prices[] = { 8.5, 7.5, 7 };
       System.out.println("Enter name for sandwich cheese (Steak, Chicken, Salad)");
       Scanner sc = new Scanner(System.in);
       String n = sc.nextLine();
       System.out.println("Enter The Quantity");
       int q = sc.nextInt();
       double total = 0;
       for (int i = 0; i < names.length; i++) 
       {
           if (n.equalsIgnoreCase(names[i])) 
           {
               total = q * prices[i];
               
eak;
           }
       }
       System.out.println("Total Cost :$" + total);
   }
}
89220/2/Remainder.java
89220/2/Remainder.java
import java.io.*;
import java.util.Scanner;
public class Remainde
{
    public static void main(String[] args) throws Exception
    {
        try
        {
            char ch;
            do
            {
                System.out.println("Enter The Number");
                BufferedReader bufferedreader = new BufferedReader(new InputStreamReader(System.in));
                String number1 = bufferedreader.readLine();
                Float value1 = Float.parseFloat(number1);
                String number2 = bufferedreader.readLine();
              ...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here