Sunday, 5 November 2017

java simple bill project



Problem 14:
Write a program that calculate the bill if unit less then 100; one unit price is 10Rs if greater then 100 but less then 200; one unit price is 13Rs if greater the 200 less then 300;  One unit price is 17Rs If greater then 300 unit price is 20;
Discripition:
Simply multiply units with suitable prices.
Solution:

public class Message {
 public static void main(String[] args) {
 
 Scanner input = new Scanner(System.in);

 System.out.print("Enter the total units: ");
 int totalBill, unit = input.nextInt();

if(unit<=100)
    totalBill=unit*10;
else if(unit>100&&unit<200)
    totalBill=unit*13;
else if(unit>200&&unit<300)
    totalBill=unit*17;
else
    totalBill=unit*20;
 System.out.println("Your total bill is "+totalBill);
 }
 }
Output:
     


No comments:

Post a Comment