Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Page 2 of 2 FirstFirst 12
Results 26 to 27 of 27

Thread: JAVA help on file: Internet Service Provider

  1. #26
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JAVA help on file: Internet Service Provider

    Check ALL the {
    make sure that there is a } that pairs with it.

  2. #27
    Junior Member
    Join Date
    Mar 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: JAVA help on file: Internet Service Provider

    package lesson2.skowronek;

    import java.util.Scanner; //Needed for the scanner class

    public class Ex3_13 {

    public static void main(String[] args) {
    String input; //To hold users input.

    char selectPackage; //To hold Internet Package

    double hourUsage, totalCharges, addCharges; //other variables

    //Create a Scanner object for keyboard input.
    Scanner keyboard = new Scanner(System.in);

    //Prompt the user to select a Internet Package.

    System.out.print("Please select the package that you have purchase.");
    input = keyboard.nextLine();
    selectPackage = input.charAt(0);


    System.out.print("Please select the amount of hours used.");

    input = keyboard.nextLine();
    hourUsage = Double.parseDouble(input);

    //Display pricing for selected package...

    switch (selectPackage)
    {
    case 'a':
    case 'A':
    if (hourUsage > 10)
    {
    addCharges = hourUsage - 10;
    totalCharges = (addCharges * 2.0) + 9.95;
    System.out.println("You have used " + hourUsage + " hours and your total is $" + totalCharges + " per month. ");
    }
    else
    {
    System.out.println("Your total is $9.95 per month.");

    }
    break;

    case 'b':
    case 'B':
    if (hourUsage > 20 )
    {
    addCharges = hourUsage - 20;
    totalCharges = (addCharges * 1.0) + 13.95;
    System.out.println("You have used " + hourUsage + " and your total is $" + totalCharges + " per month.");
    }
    else
    {
    System.out.println("Your total is $13.95 per month.");

    }
    break;

    case 'c':
    case 'C':
    System.out.println("Your total is $19.95 per month.");
    break;
    default:
    System.out.println("Invalid Choice.");
    }

    }


    }

    Go ahead and try this out, I had to due the same problem for my class and it worked nicely. The suggestion from one of your peers on this site to use an if statement was a good one. If you look in the book, generally the code assignments require that you use what was reflected in the chapter. As you pick up more concepts, tried to incorporate material covered in previous chapters when necessary. If you don't use it, you will lose it.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. Java web client - > .NET web service
    By codeJ in forum Web Frameworks
    Replies: 0
    Last Post: July 8th, 2010, 04:34 AM
  2. Replies: 2
    Last Post: November 19th, 2009, 11:55 PM
  3. Read XML from Internet Hang
    By yupingliew in forum Java Networking
    Replies: 8
    Last Post: November 9th, 2009, 09:49 AM
  4. Free java hosting service providers
    By servlet in forum Java Servlet
    Replies: 1
    Last Post: May 14th, 2009, 07:28 AM
  5. Internet Filter to display some website
    By sundarjothi in forum JavaServer Pages: JSP & JSTL
    Replies: 1
    Last Post: May 15th, 2008, 05:03 AM