Write Java programs for the following 2 problems. Run each program with 3 differ
ID: 3770404 • Letter: W
Question
Write Java programs for the following 2 problems. Run each program with 3 different inputs.
1. An appliance store (such as Target) sells dishwashers. The store clerk needs to keep track of the inventory at the beginning of the day, the number of dishwashers that came into the store from the wherehouse, the number sold on that day so that the manager knows how many dishwashers are still on the floor at the end of the day. Identify proper inputs and outputs and write the program.
2. A concert hall has 3 seating categories: Orchestra, Main floor and Balcony. Orchestra seats are $30, Main floor seats are $40 and Balcony seats are $50. The manager wants a program that allows him to enter the number of tickets sold in each seating category. The program should calculate and display the amount of revenue generated by each seating category as well as the total revenue.
Explanation / Answer
import java.io.*;
import java.util.*;
class DishwasherStore
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int total, sold;
for(int i = 0; i < 3; i++)
{
System.out.print("Enter the dishwashers came into the store from warehouse: ");
total = sc.nextInt();
System.out.print("Enter the number of dishwashers sold: ");
sold = sc.nextInt();
System.out.println("There are "+(total-sold)+" leftover dishwashers on the floor.");
}
}
}
import java.io.*;
import java.util.*;
class ConcertHall
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
int orchestra, mainFloor, balcony;
for(int i = 0; i < 3; i++)
{
System.out.print("Enter the number of tickets sold in Orchestra: ");
orchestra = sc.nextInt();
System.out.print("Enter the number of tickets sold in Mainfloor: ");
mainFloor = sc.nextInt();
System.out.print("Enter the number of tickets sold in Balcony: ");
balcony = sc.nextInt();
System.out.println("The total revenue generated is: "+(orchestra * 30 + mainFloor * 40 + balcony * 50));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.