-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExecrcise2.java
More file actions
39 lines (27 loc) · 1.04 KB
/
Execrcise2.java
File metadata and controls
39 lines (27 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package LearningWithExercises;
/*
create a shopping cart program.the user is able to enter the item set a price for each item as for the quantity of the product.
The system should give you a total based on the values entered.
*/
import java.util.Scanner;
public class Execrcise2 {
public static void main (String []args ){
//shoopping cart program
Scanner scanner = new Scanner (System.in);
String item;
double price;
int quantity;
double total=0;
char currency ='$';
System.out.print("what item would you line to buy: ");
item= scanner.nextLine();
System.out.print("Enter the price for each:");
price=scanner.nextDouble();
System.out.print("How many would you like:");
quantity= scanner.nextInt();
System.out.println("you want to buy: "+quantity+" " +item+"(s)");
total=quantity*price;
System.out.println("the total wil be "+total +" "+currency);
scanner.close();
}
}