Results 1 to 2 of 2
- 02-20-2012, 01:36 AM #1
Member
- Join Date
- Feb 2012
- Posts
- 17
- Rep Power
- 0
Problem 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:
Java Code:import java.util.*; public class DataGimmick { public static void main(String [] args) { double cost; int data; double fee; double additional; Scanner myReader = new Scanner(System.in); boolean plan; boolean A; boolean B; boolean C; //Calculate the cost for different packages. if (plan = A); { data = myReader.nextInt(); fee = (data - 150) / 150; cost = fee * 9.99; } if ((data - 150) % 150 != 0); { additional = cost + 14.99; } if (plan = B); { data = myReader.nextInt(); fee = (data - 500) / 500; cost = fee * 24.99; } { if ((data - 500) % 500 != 0); { additional = cost + 12.99; } if (plan = C); { data = myReader.nextInt(); fee = (data - 2000) / 2000; cost = fee * 39.99; } if ((data - 2000) % 2000 != 0); { additional = cost + 8.99; } { // 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?"); plan = myReader.nextBoolean(); //Print out the total monthly charge for data. System.out.printf("Your bill for the month is $%,.2f\n", cost + additional); } }
- 02-21-2012, 09:18 PM #2
Moderator
- Join Date
- Jul 2010
- Location
- California
- Posts
- 1,608
- Rep Power
- 5
Re: Problem running DataGimmick program!!
Neither do we...you should give us some context. Does it compile? Are there exceptions? If you want help, you need to describe your problem as best as you can and not hope that we will make the effort to review the problem and code in all its detail, which can be time consuming at best.am having an issue with running my program, i am not sure where i have gone wrong
Similar Threads
-
Problem running Applet in IE but works when running just Java in Netbeans?
By rodneyc8063 in forum Java AppletsReplies: 7Last Post: 12-18-2011, 04:13 AM -
Not getting why the program is not running
By jnjh in forum New To JavaReplies: 5Last Post: 04-07-2011, 10:25 AM -
Help with running the program :)
By dj_ee3 in forum New To JavaReplies: 2Last Post: 02-27-2011, 11:19 PM -
Problem with running an external program via java
By g123456 in forum New To JavaReplies: 4Last Post: 12-30-2009, 05:06 PM -
Problem in running Java swing wizard in jre 1.6 while it is running in jre 1.4
By Sanjay Dwivedi in forum AWT / SwingReplies: 0Last Post: 08-26-2009, 01:03 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks