| jeaninem71 (7) | |||
|
1) cannot get bill to output correctly 2) how do I output the description for the plan Write a program to calculate and print out cellular phone bills for one month. Fixed rate plan (code F), per Minute charge plan (code M), Home customer plan (code H), home Plus customer plan (code P), or Business customer plan (code B). • Code F: A flat $150.00 fee for unlimited minutes (not available to businesses) • Code M: A charge of $5, plus 21 cents a minute • Code H: $40 for the first 600 minutes used, plus 19 cents for each additional minute. • Code P: $64 for the first 1000 minutes used, plus 17 cents for each additional minute • Code B: $150 for up to 2,000 minutes; $210 for up to 3,000 minutes, and $240 if over 3,000 minutes No other codes should be accepted. Then prompt for a 5-digit customer account number (no leading zeros allowed) and error check value is valid. Re-prompt until a valid value is entered. This input should be read and error checked from within the main function. Next call display a menu of plan codes, along with descriptions of each, to the user. Prompt for the plan code and error check that the user entered a valid plan code (accepted in upper or lowercase). Re-prompt until a valid value is entered. If necessary (all plans except plan F), also prompt for the number of minutes used and error check that the number entered is not negative. Re-prompt until a valid value is entered. Calculate the bill total and display the results. The output should display: the customer account number, the plan chosen in words, the number of minutes used (unless the plan chosen was F), and the total amount of bill. Display neatly with descriptive text. After displaying the results, ask the user whether to execute the program again, and do so, as long as the user wishes to continue. At a minimum, the program must implement three separate functions (in addition to main), as described on the next page: • One function to read and validate the plan choice read and validate the number of minutes used. • One function to calculate the amount of the bill and return the bill amount. • One function to display the bill output. The functions must use parameters to pass required data to each function. Remember to pass all input only parameters by value, and pass all output parameters by reference.
| |||
|
|
|||
| soranz (472) | |
|
First thing I notice is that you are sending variables to your functions but never using them...declaring new ones...and using those without initializations... 27 - minutesUsed is declared in main() 41 - pass minutesUsed into function outputbill 161 - minutesUsed becomes the variable 'minutes'. minutesUsed currently does not exist in function 'outputbill' 170 - declare minutesUsed(?why?this is not the same minutesUsed as line 27) 177 - printing 'minutesUsed' (uninitialized local variable) ( should u print 'minutes' instead?) | |
|
Last edited on
|
|
| vichu8888 (176) | |||||||||
|
I think you are totally confused with parameters when passing it into a function Ill illustrate with a simple example, which MAY make u clear
1. Pass by reference(passing parameters with '&' symbol)
Output will be: 32. Pass by value(passing parameter without '&' symbol)
Now output will be: 0'&choice' gives the name of memory space where choice is located. this will allow store a new number in that memory space 'choice' gives the value of the choice itself,i.e) zero as choice value is zero, u cannot change it. u cannot assign 0=3; After editing your code, it will be like this
| |||||||||
|
|
|||||||||
| jeaninem71 (7) | |
|
Thanks so much for the help! How do I get the plan description to output on the bill output instead of just the letter? For example: YOUR MONTHLY BILL Your account number: 12345 Your plan: F - Fixed rate plan - $150 flat fee for unlimited minutes (no businesses) Your minutes: 300 Total due: $150 Slowly but surely I will figure this all out. I HOPE! | |
|
|
|
| soranz (472) | |||
|
U can do what u did in the getPlan_Minutes function where you use a switch statement to determine the output. But, since you're using the 'plan' multiple times it would probably be better to just store into a string instead of repeatedly typing it all out with cout each time.
If it gets any more complicated...like needing to have multiple messages of the same plan, u'll be better off using structures or some sort of array of strings to hold each one. | |||
|
|
|||