Facebook
From dddd, 1 Month ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 140
  1. import java.util.Scanner;
  2. public class Ex2 {
  3.  
  4.  public static void main(String[] args) {
  5.   Scanner input = new Scanner(System.in);
  6.  
  7.   String item = "";
  8.   int price = 0;
  9.   int total = 0;
  10.  
  11.   while(price>=0)
  12.   {
  13.    System.out.println("Enter item: ");
  14.    item = input.next();
  15.    if(item.equals("Exit"))
  16.     break;
  17.    price = input.nextInt();
  18.    total = total + price;
  19.   }
  20.   System.out.println("Total bill: "+total);
  21.  
  22.  }
  23.  
  24. }
  25.