Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Can you please correct the errors! #include #include using namespace std; //declaring variables char recommendedpackage, answer; string packagedetails, fname; double additionaldata, monthlypayment, balanc, additionalminutes, cost,

Can you please correct the errors!

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

#include #include using namespace std;

//declaring variables char recommendedpackage, answer; string packagedetails, fname; double additionaldata, monthlypayment, balanc, additionalminutes, cost, savedamount; double const basicadditionaldata = 0.3, basicmonthlypayment = 30.0, limitedmonthlypayment = 120, unlimitidmonthlypayment = 200;

/*creating get in value function to take in the users first and last name, phone number, used minets and data, and the choosen package*/ void getinvalue(string & fname, string lname, string & phone, int &minutes, int &dataused, char & package); void getinvalue(string & fname, string lname, string & phone, int &minutes, int &dataused, char & package) {

//outputs so the user can enter her/his first and last name cout > fname; cout > lname; cout > phone; cout > package; cout > minutes; cout > dataused; }

// creating another function to print out the price based on the used minutes and data and the choosen package double calc_price(int minutes, int dataused, char package); double calc_price(int minutes, int dataused, char package) { //for the differnet 3 different cases switch (package) {

//case 1: if the user chosed plan b or B case 'b': case 'B': //declaring the package name and the details of it package = 'B'; packagedetails = "30 AED / month includes 30 minutes. Additional minute costs 30 fills. Data usage is 30 fills per 1MB.";

//if the user exeded the set minutes then the additial charges will apply if (minutes > 30) { additionalminutes = 0.3; } //if not then no additional charges will apply else { additionalminutes = 0; } //to calculate the total balance return cost = basicadditionaldata * dataused + additionalminutes * (minutes - 30) + basicmonthlypayment;

//breaking the previous case break;

//case 2: if the user chosed plan l or L case 'L': case 'l': //declaring the package name and the details of it package = 'L'; packagedetails = "120 AED/month includes 60 minutes, 100MB of data. Additional minute costs 20 fills, and any extra data usage beyond the 100MB costs 30 fills per 1MB.";

//if the user exeded the set minutes then the additional charges will apply if (minutes > 60) { additionalminutes = 0.2; } //if not then no additional charges will apply else { additionalminutes = 0; } //if the user exedde the set data then the additional charges will apply if (dataused > 100) { additionaldata = 0.3; } //if not then no additional charges will apply else { additionaldata = 0; } //to calculate the total balance return cost = limitedmonthlypayment + (dataused - 100)*additionaldata + (minutes - 60)*additionalminutes;

//breaking the previous case break;

//case 3: if the user chosed plan U or u then case 'U': case 'u': //declaring the package name and the details of it package = 'U'; packagedetails = "200 AED/month includes unlimited calling minutes and unlimited data usage. "; return cost = unlimitidmonthlypayment;

//breaking the previous case break;

//for any other choices it will set s default and print out the following default: cout

}

//creating a new function to recommend the best packages according to the saved amount char recommendpackage(int minutes, int data); char recommendpackage(int minutes, int data) {

//declaring new variables double comparinglimited, comparingbasic, comparingunlimited;

//if the user exeded the set minutes then the additial charges will apply for the basic if (minutes > 30) { additionalminutes = 0.3; } //to calculate the compared value for the basic comparingbasic = basicadditionaldata * data + additionalminutes * (minutes - 30) + basicmonthlypayment;

//if the user exeded the set minutes then the additional charges will apply for the limited if (minutes > 60) { additionalminutes = 0.2; } //if the user exeded the set data then the additional charges will apply for the limited if (data > 100) { additionaldata = 0.3; } //to calculate the compared value for the limited comparinglimited = limitedmonthlypayment + (data - 100)*additionaldata + (minutes - 60)*additionalminutes;

//if compared basic is less than both the cpombared limited and unlimited then the saved amount will equal to if ((comparingbasic 0) { return recommendedpackage = 'B'; }

} //if compared limited is less than both the cpombared basic and unlimited then the saved amount will equal to if ((comparinglimited 0) { return recommendedpackage = 'L'; }

} //if compared unlimited is less than both the cpombared limited and basic then the saved amount will equal to if ((comparingunlimited 0) { return recommendedpackage = 'U'; } }

else if (savedamount

}

//creating a new function to print out the invoice void displayInvoice(string fname, string lname, string phone, int minutes, int dataused, char package, double cost); void displayInvoice(string fname, string lname, string phone, int minutes, int dataused, char package, double cost) {

//if the user entered 1 as an answer, the following loop will be repeated until it breaks do { //to print out the users the invoice cout

//if the saved amount was greater than and does not equal to zero then it should print out the following if ((savedamount != 0) && (savedamount > 0)) { cout

//else if the saved amount eas less than or equal to zero then it should print out the following else if (savedamount

cout > answer;

// if the user entered an invalid answer other than 2 or 1 if ((answer != '1') && (answer != '2')) { cout > answer; cout

//if the user entered 2 as an answer the following output will print out if (answer == '2') { cout

getinvalue(fname, lname, phone, minutes, dataused, package); calc_price(minutes, dataused, package); recommendpackage(minutes, data); displayInvoice(fname, lname, phone, minutes, dataused, package, cost); }

recommendpackage function must be defined as specified below. The function takes in the minutes used and data used, and returns a character related to the recommended package (B, L, or U) that has more saving . char recommendpackage(int minutes, int data) displaylnvoice function must be defined as specified below. The function takes in the first name, last name, phone number, minutes, data used, package and cost, and formats the invoice and outputs it to the screen for the user void displayInvoice(string fname, string lname, string phone, int minutes, int dataused, char package, double cost) create the proper function calls within your program to solve the required problem uired that y The required functions mentioned above our program includ . The first block of comments that has your name, program description, and academic integrity statement. See Programming Requirements document in iLearn for details. Proper comments for your code Each function should have its own description, parameters to pass, and what it returns as block of comment before the function definition Meaningful variable names Make your program easy to read. Use proper indentation Make use of constant variables Error checking. For example, if the user enters a package that is not B, L, or U. Also, if the user enters something other than yes or no to enter another phone number, etc. 1. A printout of all your source code (cpp file) directly from visual studio. DONOT COPY AND PASTE YOUR CODE INTO A WORD DOCUMENT A printout of your output screenshots (Your output runs should cover all cases) Log into iLearn and locate Assignment 3 Assessment in your section folder. Upload your homework cpp source file that you created 2. 3. (10) -Neat and readable code Overall Logic (5) (60) - Comments Meaningful variables & use of constants (10 Input/Output results & format (10) -Proper submission If functions are not used, the grade ZERO will be given for this assignment

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Building The Data Warehouse

Authors: W. H. Inmon

4th Edition

0764599445, 978-0764599446

More Books

Students also viewed these Databases questions