#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Question Help How To Solve This Question


    QUESTION 2: Internet Service Provider

    An Internet service provider has three different subscription packages for its customers.

    Package A: For $9.95 per month 10 hours of access are provided. Additional hours are $2.00 per hour.

    Package B: For $13.95 per month 20 hours of access are provided. Additional hours are $1.00 per hour.

    Package C: For $19.95 per month unlimited accesses are provided.

    Write a program that calculates a customerís monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B or C) and the number of hours that were used. It should then display the total charges.

    ------------------------------------------------------------

    First of all, im sorry im this post was not in a correct section. This is my first assignment about object oriented programming. Can you help me how to solve question? What should i write on bluej? Please anyone who expert about this please help me
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,995
    Rep Power
    481
    Please show your effort, even if all you're able to write is a literate description of a possible algorithm.
    [code]Code tags[/code] are essential for python code and Makefiles!
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0
    Code:
    import java.util.*;
    
    public class Bill
        {
            public static void main(String[] args)
            {
                String input1;
                char pack;
                double mult1,mult2,hour;
                Scanner keyboard = new Scanner(System.in);
                
                System.out.println("Internet service provider deviced to 3 packages: ");
                System.out.println("Package A: $9.95 per month 10 hours of access are provided.\n\t Additional hours are $2.00 per hour.");
                System.out.println("Package B: $13.95 per month 20 hours of access are provided.\n\t Additional hours are $1.00 per hour.");
                System.out.println("Package C: $19.95 per month unlimited accesses are provided.");
                System.out.println("Please enter the letter package(A,B,or C): ");
                input1 = keyboard.nextLine();
                pack = input1.charAt(0);
               
                
                switch (pack)
                {
                    case 'a':
                    case 'A': System.out.println("Please enter number of hours that were used: ");
                              hour = keyboard.nextDouble();
                              mult1 = 9.95 + (hour * 2.00);
                              System.out.print("Package A:\nThe total charges is $ " + mult1);
                              break;
                    case 'b':
                    case 'B': System.out.println("Please enter number of hours that were used: ");
                              hour = keyboard.nextDouble();
                              mult2 = 13.95 + (hour * 1.00);
                              System.out.print("Package B:\nThe total charges is $" + mult2);
                              break;
                    case 'c':
                    case 'C':System.out.print("Package C:\nThe total is $19.95.");
                             System.out.print(" \nTHANK YOU !!!  " );   
                             break;
                    default:
                            System.out.print("That not A, B, or C!");
                }
            }
        }

    ------------------------------------------------------------

    I've tried this coding just now, but is it correct
  6. #4
  7. The bad and the ugly...
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2007
    Location
    Oz... No??? Neverland then?
    Posts
    142
    Rep Power
    0
    i dont see why that wouldn't work? I dont have a java IDE installed on my computer at the moment, and i havent messed with it in a couple years but the idea behind it seems sound.

    does it compile?
    "Life is not a journey with the intent on arriving at the finish line in a pretty and well preserved body. But rather to skid in broadside, totally worn out, thoroughly used up and loudly proclaiming, "Wow! What a ride!" -Anonymous
    Halo! || Diablo 2 LOD Modding || OLGA's BACK!
  8. #5
  9. Contributing User
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Aug 2010
    Location
    Eastern Florida
    Posts
    3,724
    Rep Power
    348
    is it correct
    Does it compile and execute?
    Does it give the correct answers in all cases?
    If the answers to the above are all YES, then the code is probably correct.
  10. #6
  11. Lord of the Dance
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Oct 2003
    Posts
    3,730
    Rep Power
    1959
    Two hints you should look more careful at: provided and Additional hours

IMN logo majestic logo threadwatch logo seochat tools logo