+1 678 648 4277 
Table Of Contents
  • A Program That Computes Total Cost of Group of People Attending a Theme Park

A Program That Computes Total Cost of Group of People Attending a Theme Park

Write a generic program to compute the total cost of a group of people attending a theme park. Save the filename as lastname_mid1.java
Age range Theme park ticket per person
under 5 year $45.00
under 11 year $75.00
under 17 year $120.00
Adults $150.00
Total theme park cost Group discount
0-$1000 No discount
$1001-$2000 5%
$2001-$3000 8%
$3001 and up 10%
Age range Price of one meal
Under 11 $10
11 or above $20
User Input:
Enter the number of under 5 year old = 2
Enter the number of under 11 year old = 3
Enter the number of under 17 year old = 4
Enter the number of adults = 8
Expected Output:
Total group cost before discount = 2(45) + 3(75) + 4(120) + 8(150) = $1,995.00
Total group cost after discount = 0.95(1995) = $1,895.25
Total cost of Meal = (2 + 3)(10) + (4 + 8)(20) = $290.00
Total cost = 1895.25 + 290 = $2185.25
Java Code Solution
importjava.util.Scanner;
public class mid1 {
private static double getDiscount(double cost) {
if(cost <= 1000) {
return 0;
    } else if (cost <= 2000) {
return 0.05;
    } else if (cost <= 3000) {
return 0.08;
    }
return 0.1;
  }
public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
System.out.print("Enter the number of under 5 year old = ");
int lessThan5 = scanner.nextInt();
System.out.print("Enter the number of under 11 year old = ");
int lessThan11 = scanner.nextInt();
System.out.print("Enter the number of under 17 year old = ");
int lessThan17 = scanner.nextInt();
System.out.print("Enter the number of adults = ");
int adults = scanner.nextInt();
doublegroupCost = lessThan5*45 + lessThan11*75 + lessThan17*120 + adults*150;
doublegroupCostAfterDiscount = groupCost * (1 - getDiscount(groupCost));
doublemealCost = ((lessThan5 + lessThan11) * 10) + ((lessThan17 + adults) * 20);
doubletotalCost = groupCostAfterDiscount + mealCost;
System.out.println("\nTotal group cost before discount = $" + groupCost);
System.out.println("Total group cost after discount = $" + groupCostAfterDiscount);
System.out.println("Total cost of Meal = $" + mealCost);
System.out.println("Total cost = $" + totalCost);
  }
}
A Java Program That Computes The Total Production Units
A manufacturing plant produces two types of units, A and B as follows. The cost of producing each unit A is $0.90 and each unit B is $0.80.
Hour 0 starts at midnight and hour 1 is at 1 am.
Write a generic program to compute the total of producing both types of units after any given number of hours such as 10, 100 or 200. Save the filename as lastname_mid2.java
Linked List with Small Modification 5
Input:
Enter the number of hours = 10
Linked List with Small Modification 6
Java Code Solution
importjava.util.Scanner;
public class mid2 {
public static void main(String[] args) {
doublecostA = 0.9;
doublecostB = 0.8;
System.out.print("Enter the number of hours: ");
    Scanner scanner = new Scanner(System.in);
int hours = scanner.nextInt();
System.out.println("Hour\tUnitsA\tUnitsB\tTotal Cost");
intproductionA = 0;
intproductionB = 0;
inttotalCost = 0;
for (inti = 1; i< hours + 1; i++) {
int hour = (i-1)%24;
if(hour == 5){
productionB = 40;
      } else if(hour >= 6 && hour < 9) {
productionA = 50;
productionB = 40;
      } else if(hour >= 9 && hour < 18) {
productionA = 80;
productionB = 100;
      } else if(hour >= 18 && hour < 21) {
productionA = 50;
productionB = 40;
      } else if(hour == 21) {
productionA = 50;
      }
totalCost += productionA*costA + productionB*costB;
System.out.println(hour + "\t\t" + productionA + "\t\t" + productionB + "\t\t" + totalCost);
    }
  }
}