I need this problem to be divided into a Business and Tester class. It needs to
ID: 3719287 • Letter: I
Question
I need this problem to be divided into a Business and Tester class. It needs to repeat and ask the user if they want to place another order after their first and so on. The program should ask for the rest of the following and display it to the console for the user to see.
Problem description A renowned manufacturer of computers wants a program to calculate the cost of each order that a client places. Products have a type, cost and quantity. The cost of "ultraportable laptops" type of computers is $400, of "laptops" type of computers is $800 and of "server" type of computers is $1200. If the client orders a total of 5-10 computers they get a discount of 2%, if they order 10 or up to 50 computers they get a discount of 7% and if they order more than 50 computers, they get a discount of 12%. No discounts are given for orders of less than 5 computers. The final cost computed should take all of these considerations into account. This time the client is a supplier that supplies computers to other retailers. This means that they will place multiple orders for various clients. The program should prompt the user for the quantity of each type of computer and provide the following information to the client: The number of ultraportable laptops in the order The number of laptops in the order The number of servers in the order The total number of computers ordered The order subtotal amount The discount percentage and amount The order total after discount . The client should be able to place as many orders as they like and should see all of the above information for each order. Technical Constraints: Project needs to be neatly organized into business class with instance methods and tester class Project CodeExplanation / Answer
Solution:
import java.io.*;
import java.util.Scanner;
public class Main{
public static void main(String []args){
//command to prompt client to enter no of ultraportable laptop he want
System.out.println("The quantity ultraportable laptops");
//taking input from client
Scanner scan = new Scanner(System.in);
int a = scan.nextInt(); // a is number of ultraportable laptop
//command to prompt client to enter no of laptop computer he want
System.out.println("The quantity laptops");
//taking input from client
Scanner scan1 = new Scanner(System.in);
int b = scan1.nextInt(); //b is no of laptop
//command to prompt client to enter no of server computer he want
System.out.println("The quantity server laptops");
//taking input from client
Scanner scan2 = new Scanner(System.in);
int c = scan2.nextInt(); // no of server computer
int t = a+b+c; // t is total no of computer
//case when order is less than 5 coputer
if(t<=5){
int d = 400*a + 800*b + 1200*c; // d is cost
System.out.println("The total cost is $"+d);
}
//case when no of computer is more than 5 less than 10
if(t>5 && t<=10){
int d = 400*a + 800*b + 1200*c; // d is cost
d = 98*d/100; // cost after discount
System.out.println("The total cost is $"+d);
}
//when no of computer is more than 10 and less than 50
if(t>11 && t<=50){
int d = 400*a + 800*b + 1200*c; // d is cost
d = 93*d/100; // cost after discount
System.out.println("The total cost is $"+d);
}
//when no of computer is more than 50
if(t>50){
int d = 400*a + 800*b + 1200*c; //d is cost
d = 88*d/100; // cost after discount
System.out.println("The total cost is $"+d);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.