Problem description: A renowned manufacturer of computers wants a program to cal
ID: 3872907 • Letter: P
Question
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 11 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.
The program should prompt the user for the quantity of each type of computer and provide the total cost of the order.
Write source code in Dr. Java, test it with the test cases created in the earlier deliverable and submit your .java file here.
Code should have clear comments explaining the purpose of the program and the variables.
Explanation / Answer
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.