Hi currently need help with editing this code. My professor said my code needs to have if, if-else, and if-else if statements in it. From what it looks like I'm missing if-else-if statements in my code. I need help with editing the code with if-else-if statements including any other "if or if-else" if needed in the code. I provided pictures of the code instructions and how the output and input validation needs to look. here's the code I currently have: #include #include #include using namespace std; int main() { //variables and constants int packageType; double dataUsed; double monthlyCharges = 0.0; // Name of the program cout << "iMobile Bill Calculator ..." << endl; // Display the pacakge options for user to pick while (true) { cout << "\nSelect a subscription :" << endl;; cout << "\t\t1. Package A" << endl; cout << "\t\t2. Package B" << endl; cout << "\t\t3. Package C" << endl; cout << "Package: "; cin >> packageType; // When a package number is not vaild if (packageType >= 1 && packageType <= 3) break; else cout << "Error ... Invalid package. Try again." << endl; } // When Gigabytes entered is not valid while (true) { cout << "\nHow many gigabytes of data were used? "; cin >> dataUsed; if (dataUsed < 0) { cout << "Error ... Invalid gigabytes entered. Try again." << endl; } else break; } switch (packageType) { // Monthtly Charges for Plan A case 1: { if (dataUsed >= 0 && dataUsed <= 4) { monthlyCharges = 39.99; } // Monthtly Charges for Plan A with additional data costs else { monthlyCharges = 39.99 + (dataUsed - 4) * 10; } break; } // Monthtly Charges for Plan B case 2: { if (dataUsed >= 0 && dataUsed <= 8) { monthlyCharges = 59.99; } // Monthtly Charges for Plan B with additional data costs else { monthlyCharges = 59.99 + (dataUsed - 8) * 5; } break; } // Monthly Charges for Plan C case 3: { monthlyCharges = 75; break; } } // Display the monthly total amount cout << "The total amount due is $" << monthlyCharges << endl; cout << endl; return 0; }
Hi currently need help with editing this code. My professor said my code needs to have if, if-else, and if-else if statements in it. From what it looks like I'm missing if-else-if statements in my code. I need help with editing the code with if-else-if statements including any other "if or if-else" if needed in the code. I provided pictures of the code instructions and how the output and input validation needs to look.
here's the code I currently have:
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
int main()
{
//variables and constants
int packageType;
double dataUsed;
double monthlyCharges = 0.0;
// Name of the program
cout << "iMobile Bill Calculator ..." << endl;
// Display the pacakge options for user to pick
while (true) {
cout << "\nSelect a subscription :" << endl;;
cout << "\t\t1. Package A" << endl;
cout << "\t\t2. Package B" << endl;
cout << "\t\t3. Package C" << endl;
cout << "Package: ";
cin >> packageType;
// When a package number is not vaild
if (packageType >= 1 && packageType <= 3)
break;
else
cout << "Error ... Invalid package. Try again." << endl;
}
// When Gigabytes entered is not valid
while (true) {
cout << "\nHow many gigabytes of data were used? ";
cin >> dataUsed;
if (dataUsed < 0) {
cout << "Error ... Invalid gigabytes entered. Try again." << endl;
}
else
break;
}
switch (packageType) {
// Monthtly Charges for Plan A
case 1: {
if (dataUsed >= 0 && dataUsed <= 4) {
monthlyCharges = 39.99;
}
// Monthtly Charges for Plan A with additional data costs
else {
monthlyCharges = 39.99 + (dataUsed - 4) * 10;
}
break;
}
// Monthtly Charges for Plan B
case 2: {
if (dataUsed >= 0 && dataUsed <= 8) {
monthlyCharges = 59.99;
}
// Monthtly Charges for Plan B with additional data costs
else {
monthlyCharges = 59.99 + (dataUsed - 8) * 5;
}
break;
}
// Monthly Charges for Plan C
case 3: {
monthlyCharges = 75;
break;
}
}
// Display the monthly total amount
cout << "The total amount due is $" << monthlyCharges << endl;
cout << endl;
return 0;
}
![Output Samples
Microsoft Visual Studio Debug Console
iMobile Bill Calculator ...
Select a subscription package:
1. Package A
2. Package B
3. Package C
Package: 1
How many gigabytes of data were used? 12.5
The total amount due is $124.99
The Text version of the Output samples for the iMobile Service Provided program.
Input Validation
| Microsoft Visual Studio Debug Console
iMobile Bill Calculator ...
Select a subscription package:
1. Package A
2. Package B
3. Package c
Package: 0
Error
Invalid package. Try again.
...
A Microsoft Visual Studio Debug Console
iMobile Bill Calculator ...
Select a subscription package:
1. Package A
2. Package B
3. Package C
Package: 2
How many gigabytes of data were used? -100
Invalid gigabytes entered. Try again.
Error
...](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffc533774-2db2-4c40-ad62-e47c502b55d9%2F994f3f65-64b8-465c-87a1-5ec4730bea16%2Fk9l3kvs_processed.png&w=3840&q=75)
![iMobile Service Provided
O iMobile.cpp
iMobile is a mobile phone service company that offers three different data plans to its customers.
Plan A:
Price: $39.99 per month.
Data allowance: Includes 4 gigabytes of data. Additional data costs $10 per gigabyte.
Plan B:
Price: $59.99 per month.
Data Allowance: Includes 8 gigabytes of data. Additional data costs $5 per gigabyte.
O Plan C:
Price: $69.99 per month.
Data Allowance: Unlimited
Write a program that calculates a customer's monthly bill. It should prompt the user for the customer's plan and the number of
gigabytes of data used. It should then calculate and display the total amount due.
Notes
Use a menu to prompt user for Plan.
O Input Validation
Display an error message if the user enters an invalid menu option.
Do not allow negative values for data used.
O Display amount due, formatted with a precision of two decimal values.](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2Ffc533774-2db2-4c40-ad62-e47c502b55d9%2F994f3f65-64b8-465c-87a1-5ec4730bea16%2F9g4ltz_processed.png&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![Database System Concepts](https://www.bartleby.com/isbn_cover_images/9780078022159/9780078022159_smallCoverImage.jpg)
![Starting Out with Python (4th Edition)](https://www.bartleby.com/isbn_cover_images/9780134444321/9780134444321_smallCoverImage.gif)
![Digital Fundamentals (11th Edition)](https://www.bartleby.com/isbn_cover_images/9780132737968/9780132737968_smallCoverImage.gif)
![C How to Program (8th Edition)](https://www.bartleby.com/isbn_cover_images/9780133976892/9780133976892_smallCoverImage.gif)
![Database Systems: Design, Implementation, & Manag…](https://www.bartleby.com/isbn_cover_images/9781337627900/9781337627900_smallCoverImage.gif)
![Programmable Logic Controllers](https://www.bartleby.com/isbn_cover_images/9780073373843/9780073373843_smallCoverImage.gif)