Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

COMP 1900-Fall 2018 Lab 3 Homework: Conditionals (12 pts) Number of People: Indi

ID: 3755111 • Letter: C

Question

COMP 1900-Fall 2018 Lab 3 Homework: Conditionals (12 pts) Number of People: Individual Due: By the beginning of next week's lab session Grader: Please refer to the COMP 1900 syllabus for your lab TA. Questions about grading? Contact him/her first! Coding Style: Use camelCase for variable names, use consistent indentation in your code, and include a reasonable amount of comments throughout your code. The TAs may deduct points for poor coding style. Within the 1900 folder on your desktop, create a new folder named Lab3HW 1. (4 pts) U.S. federal government employees are paid on a scale according to their grade and step. There are a total of 15 grades, each of which consists of 10 steps. Here's a table of 2018 annual salaries (in S) for the first 4 grades and the first 3 steps from each: Grade Step 1 Step2 Step 3 18785 19414 20030 21121 2162422323 23045 23813 24581 25871 26733 27595 s:/www.opm govipolicyd govpolicy-data-oversight Within your Lab3HW folder, create a new file named SalaryCalculator.java. Write a program that uses the switch statement to determine the salary of an employee. Your program should allow the user to enter need to implement only the first 4 grades and first 3 steps. Include default cases to cover situations where the user enters an invalid grade or step. Do not use any f Hint: You can nest switch statements, just like you can nest if statements

Explanation / Answer

I am sending the codes for both problems.Feel free comment if there is any doubt.All the best.

SalaryCalculator.java

import java.util.*;

public class SalaryCalculator {
   public static void main(String[] args) {
       Scanner sc=new Scanner(System.in);
       String grade;
       String step;
       System.out.println("Enter Grade : ");
       step=sc.next();
       System.out.println("Enter Step : ");
       grade=sc.next();
       switch(grade) {
       case "1":
           switch(step) {
               case "1":
                   System.out.println("Salary = $18785");
                   break;  
               case "2":
                   System.out.println("Salary = $19414");
                   break;
               case "3":
                   System.out.println("Salary = $20039");
                   break;
               default:
                   System.out.println("Invalid");
                   break;
           }
           break;
       case "2":
           switch(step) {
               case "1":
                   System.out.println("Salary = $21121");
                   break;
               case "2":
                   System.out.println("Salary = $21624");
                   break;
               case "3":
                   System.out.println("Salary = $22323");
                   break;
               default:
                   System.out.println("Invalid");
                   break;
           }
           break;
       case "3":
           switch(step) {
               case "1":
                   System.out.println("Salary = $23045");
                   break;
               case "2":
                   System.out.println("Salary = $23813");
                   break;
               case "3":
                   System.out.println("Salary = $24581");
                   break;
               default:
                   System.out.println("Invalid");
                   break;
           }
           break;
       case "4":
           switch(step) {
               case "1":
                   System.out.println("Salary = $25871");
                   break;
               case "2":
                   System.out.println("Salary = $26733");
                   break;
               case "3":
                   System.out.println("Salary = $27595");
                   break;
               default:
                   System.out.println("Invalid");
                   break;
           }
           break;
       default:
           System.out.println("Invalid");
           break;
       }
       sc.close();
      
   }
  
  

}

MovieTickets.java

import java.util.Scanner;

public class MovieTickets {
   public static void main(String args[]) {
       int chqty=0;
       int regqty=0;
       int senqty=0;
       double ch=0;
       double reg=0;
       double sen=0;
       int timing=0;
       String show="";
       int a=0;
       int c=0;
       Scanner sc=new Scanner(System.in);
       System.out.println("Whate time is your showing?");
       timing=sc.nextInt();
       if(timing>=1700) {
           reg=10.5;
           ch=4;
           sen=8;
           show="Evening rates";
       }
       else {
           reg=8;
           ch=0;
           sen=6.5;
           show="Matinee rates";
       }
      
       boolean stat=true;
       while(stat){
           c++;
           System.out.println("Please enter the age of party number "+c+":");
           System.out.println("(any negative value to exit)");
           a=sc.nextInt();
           if(a<0) {
               stat=false;
           }
           else if(a<=10) {
               chqty++;
           }
           else if(a>=65) {
               senqty++;
           }
           else {
               regqty++;
           }
       }
       System.out.println("Order Summary");
       System.out.println("("+show+")");
       System.out.println("Regular : $"+reg+" x "+regqty+" = $"+reg*regqty);
       System.out.println("Child : $"+ch+" x "+chqty+" = $"+ch*chqty);
       System.out.println("Senior : $"+sen+" x "+senqty+" = $"+sen*senqty);
       System.out.println("Total : $"+(reg*regqty+ch*chqty+sen*senqty));
      
      
   }

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote