hello

Ads

 
 

Share on Google+Share on Google+

siti umairah
hello
1 Answer(s)      6 years and 10 months ago
Posted in : Java Beginners

tq so much 4 helping me...i really appreciate it... :)... i've another question..n try to do it...

an internet service provider has three different subscription packages for its customers:

package A : for RM9.99 per month 10 hours for access are provided. additional hours are RM2.99 per hour.

package B : for RM19.99 per month 20 hours of access are provided. additional hours are RM1.99 per hour.

package C : for RM29.99 per month unlimited access is provided.

write a program that calculates a customer's monthly bill. it should store the letter of the package that customer has purchased (A,B or C) and the number of hours that were used. the program should display the total charges.

here my coding so far...

import java.util.*; public class MonthlyBill { public static void main (String[]args) { double payrate=0; int hours;

Scanner scan=new Scanner(System.in); System.out.println("Enter customer's name: "); String name=scan.nextLine();

System.out.println("Enter package('A' or 'B' or 'C') : "); String pack=scan.nextLine();

if(pack.equalsIgnoreCase("A")) { payrate=9.99; System.out.println("Enter your customer's hour here:"); int hour=scan.nextInt();

  if(hours >= 10)
  payrate= payrate * 2.99;

} else if(pack.equalsIgnoreCase("B")) { payrate=19.99; System.out.println("Enter your customer's hour here:"); int hour=scan.nextInt();

  if(hours >= 20)
  payrate= payrate * 1.99;

} else if(pack.equalsIgnoreCase("C")) { payrate=29.99; System.out.println ("No extra charge for your additional hours"); System.out.println ("You get unlimited access"); }

  System.out.println ("Total monthly bill \n" + payrate);

} }

i think there is so many error...please try check it out..

Ads
View Answers

October 30, 2010 at 3:10 PM


Hello Friend,

We have modified your code:

import java.util.*; 
public class MonthlyBill {
    public static void main (String[]args) {
        double payrate=0; //int hours=0;
        double hr=0;

Scanner scan=new Scanner(System.in); 
System.out.println("Enter customer's name: ");
String name=scan.nextLine();

System.out.println("Enter package('A' or 'B' or 'C') : ");
String pack=scan.nextLine();

if(pack.equalsIgnoreCase("A")) {

    System.out.println("Enter your customer's hour here:");
    double hour=scan.nextDouble();
    payrate=9.99;
    if(hour >10)
       hr = hour - 10;
  double ch = hr * 2.99;
  payrate = payrate+ ch;
  } 
else if(pack.equalsIgnoreCase("B")) { 

    System.out.println("Enter your customer's hour here:");
    double hour=scan.nextDouble();
    payrate=19.99;
  if(hour >20)
       hr = hour - 20;
      double ch = hr * 1.99;
  payrate= payrate +ch;

} else if(pack.equalsIgnoreCase("C")) {
    payrate=29.99;
    System.out.println("No extra charge for your additional hours");
    System.out.println ("You get unlimited access"); 
    }

  System.out.println ("Total monthly bill \n" + payrate);
    }
}

Thanks


Ads









Related Tutorials/Questions & Answers:
hello
Java Error in Hello World  Java Error in Hello World
hello
Java Hello World  HELLO World program in Java
Advertisements
Hello
Hello  Hello sir i want to store upload doc file in ms access by using servlet. Can i store file in access.one another things access only text size is 255 character but my file is up to 2mb how i can store
Hello ..
Hello ..  Hello, I need a code for .. Want to read csv file (which is having name nd mobile number) from jsp and if i give search by name mobile number should get displayed and if i give mobile number name should get
hello
character is vowel or not.   Hello Friend, Try the following code
hello
there is so many error...please try check it out..   Hello Friend, We have
Hello Eyeryone...
Hello Eyeryone...  how to download java material in roseindia.net website material please kindly help me... by visu
Hello world
Hello world (First java program)   ... and can be run on any operating System. Writing Hello World program is very simple. To write the Hello world program you need  simple text editor like note
print hello n hi
print hello n hi  how to write a java program that prints "hello" 5 times, "hi" 1 time n again "hello" 4 times..?? do reply
Hello world program
Hello world program  hello world program   class Hello{ public static void main(String[] args) { System.out.println("Hello World"); } } For more information, visit the following link: http
Hello World in servlet
Hello World in servlet  Hello World example in servlet ?   import java.io.*; import javax.servlet.*; import javax.servlet.http.*; public..., IOException { PrintWriter out = res.getWriter(); out.println("Hello
hello in vertical manner
hello in vertical manner  How to print HELLO as in vertical manner   Hi, Try this: class HelloExample { public static void main(String[] args) { String str="HELLO"; char ch[]=str.toCharArray
Hello World - Java Beginners
Hello World  Java Beginner - 1st day. Looked at the Hello World script and thought I would give it a try....I created the script in Notepad. Saved...){ System.out.println("Hello World!"); } } what am I doing wrong. Am I expecting
Hello - Java Beginners
Hello  Hello I have a two button update and delete I want to user click on update button then msg will be displayed in msg box Are u sure want to update If user click yes then all record will be updated
J2ME Hello World Example
J2ME Hello World Example       This is the simple hello world application. In this example we are creating a form name "Hello World" and creating a string message "
Hello World Program
Hello World Program  write a java program that continuously prints HelloWorld! to the screen(once every second ) and exists when press the enter key... = new DisplayMessageContinuously("Hello World ", 1000); th.start
Version of com.lijinchao>hello dependency
List of Version of com.lijinchao>hello dependency
Version of com.lijinchao>hello dependency
List of Version of com.lijinchao>hello dependency
EJB Hello world example
EJB Hello world example       Creating and testing the "Hello World" Example is the very first... example we are going to show you, how to create your first hello world example
hello there i need help
hello there i need help  : i need to do a program like this: Automatic Teller Machine [B] Balance [D] Deposit [W] Withdrawal [Q] Quit select you OPtions: once i have chosen an option then i should proceed here if i choose b
pring Hello World Application
Spring Hello World Application       Hello World Example using Spring, The tutorial given below describes you the way to make a spring web application that displays Hello World
Java Hello World code example
Java Hello World code example  Hi, Here is my code of Hello World program in Java: public class HelloWorld { public static void main(String[] args) { System.out.println("Hello, World
Creating Hello World JSP Page
Creating Hello World JSP Page  Hi, I am trying to create Hello World example in JSP. How to create Hello World JSP page? Thanks   Hi.... Then ad some code to it. You may add following code : <%="Hello World!" %>
java hello and timer alert application
java hello and timer alert application  Hi, Please help me create a simple Java application that can display "Hello world" and current Time alert on mobile device screen using mobile screen emulator. Regards
Version of com.rabidgremlin>hello-world dependency
List of Version of com.rabidgremlin>hello-world dependency
How to create Applet Hello World?
How to create Applet Hello World?  Hi, What is Applet in Java? How to create Applet Hello World? Thanks   Hi, Applet is Java Program..." WIDTH=700 HEIGHT=500> Java - Applet Hello World. Thanks