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.

Results 1 to 3 of 3

Thread: Issue with running DataGimmick program

  1. #1
    Junior Member
    Join Date
    Feb 2012
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Issue with running DataGimmick program

    good day all,
    i am having an issue with running my program, i am not sure where i have gone wrong, i would appreciate it if someone could help me asap.

    Thank you

    here is what i was instructed to do:
    You are to write a program for the DataGimmick wireless data provider company. The company
    has three possible plans that consumers can sign up for, as follows:
    Package: Monthly Fee: Included MB: Cost Per Additional (up to) 150 MB:
    A $9.99 150 14.99
    B $24.99 500 12.99
    C $39.99 2000 8.99
    Note that additional data beyond the “Included MB” may only be bought in increments of 150MB,
    even if only a portion as little as 1 additional MB is used.
    Your task is to write a program that:
    • prompts the user for and reads in the exact number of MB of data they used (which cannot
    have a fractional portion).
    • prompts the user to enter the letter corresponding to their plan and reads in that plan’s letter.
    • prints out the total monthly charge (in dollars and cents) for data usage for that user, based
    on what they entered.

    here is my code:
    import java.util.*;
     
    public class DataGimmick
    {
     
     
     
       public static void main(String [] args)
       {
    	  public static void main(String [] args)
       {
    	   double cost;
    		   int data;
    		   double fee;
    		   double additional;
    		   Scanner myReader = new Scanner(System.in);
    		   char A;
    		   char B;
    		   char C;
    		   String option;
    		   // Prompt User for the data usage.
    		   System.out.print("How Much Data Did You Use?");
    		   data = myReader.nextInt();
     
    			// Prompt User for the package plan.
    		   System.out.print("Which Plan Are You Using?");
    		   myReader.next();
     
     
     
     
    	   //Calculate the cost for different packages.
     
    	   if (option A);
    	   {   
     
    		   fee = (data - 150) / 150;
    		   cost = fee * 9.99;
    	   }   
     
     
    	   if ((data - 150) % 150 != 0);   
    	   {   additional = cost + 14.99;
     
    	   }
     
     
    	   if (option = B);
    	   {
     
    	       fee = (data - 500) / 500;
    	       cost = fee * 24.99;
    	   }
     
    	   {
    	   if ((data - 500) % 500 != 0);   
    	   {   additional = cost + 12.99;
     
    	   }   
     
     
     
    	   if (option = C);
    	   {
     
    	       fee = (data - 2000) / 2000;
    	       cost = fee * 39.99;
    	   }
     
     
     
    	   if ((data - 2000) % 2000 != 0);   
    	   {   additional = cost + 8.99;
     
    	   }
     
     
    	 //Print out the total monthly charge for data.
    	   System.out.printf("Your bill for the month is $%,.2f\n", cost + additional); 
    	   }
        }
     
    }
    Last edited by Bentino; February 19th, 2012 at 08:11 PM.


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

    Default Re: Issue with running DataGimmick program

    i am not sure where i have gone wrong
    Please explain. Post all error messages.
    If the output is not what you want, post the output and add comments saying what is wrong with it and show what it should be.

  3. #3
    Think of me.... Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    1,136
    My Mood
    Grumpy
    Thanks
    20
    Thanked 82 Times in 78 Posts
    Blog Entries
    1

    Default Re: Issue with running DataGimmick program

    public static void main(String [] args)
    {
    public static void main(String [] args)
    {
    What's this?

Similar Threads

  1. [SOLVED] Program is running successfully but still getting error message..
    By sumit043020701 in forum What's Wrong With My Code?
    Replies: 2
    Last Post: December 24th, 2011, 12:26 AM
  2. Running into a problem with my program.
    By letsgetlifted in forum What's Wrong With My Code?
    Replies: 9
    Last Post: December 9th, 2011, 07:09 PM
  3. [SOLVED] Making Binary Converter script from scratch, running into math issue.
    By mwebb in forum What's Wrong With My Code?
    Replies: 9
    Last Post: November 8th, 2011, 07:47 PM
  4. NullPointerException when running program...
    By RiskyShenanigan in forum What's Wrong With My Code?
    Replies: 3
    Last Post: March 12th, 2011, 04:30 PM
  5. Textpad Program Running Problems
    By Paddy in forum Java IDEs
    Replies: 4
    Last Post: January 27th, 2010, 09:14 PM