Write a program to calculate an Internet browsing bill. Use the conditions specified as follows:
1 hour-Rs 40
½ hour- Rs 20
For unlimited hours in a day- Rs 200
The owner should enter the number of hours spent on browsing.
import java.util.Scanner;
public class InternetBillCalcuation {
public static void main(String[] args){
float bill,spentHour;
Scanner sc=new Scanner(System.in);
System.out.println("Please enter the number of hour");
spentHour=sc.nextFloat();
System.out.println("Total number of hour spent in browsing:"+spentHour);
if(spentHour>1){
bill=40*spentHour;
}else{
bill=20*spentHour;
}
System.out.println("The internet bill is :"+bill);
}
}
Output:
Comments
Leave a comment