Monday, 26 November 2018

Problem Set 1. Mobile Service Provider - Part 1 | Asad Ali



Problem Set 1. Mobile Service Provider - Part 1

A mobile phone service provider has three different subscription packages for its customers:
• Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute.
• Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute.
• Package C: For $69.99 per month unlimited minutes provided.
Write a program that calculates a customer’s monthly bill. It should ask which package the customer has purchased and how many minutes were used. It should then display the total amount due.
Input Validation: Be sure the user only selects package A, B, or C.
/// Problem Set 1. Mobile Service Provider - Part 1

#include <iostream>
using namespace std;
int main()
{
char choice;
int mins, extramins;
double extraCharges, dueAmount;
cout << "\t\t\t\tMobile Service Provider" << endl;
cout << "--------------------------------------------------------------------------------------------------" << endl;
cout << "Package A: For $39.99 per month 450 minutes are provided. Additional minutes are $0.45 per minute." << endl;
cout << "Package B: For $59.99 per month 900 minutes are provided. Additional minutes are $0.40 per minute." << endl;
cout << "Package C: For $69.99 per month unlimited minutes provided." << endl;
cout << "--------------------------------------------------------------------------------------------------" << endl;
cout << "Choose a package out of A, B and C : ";
cin >> choice;
switch ( choice )
{
case 'A':
case 'a':
cout << "How many minuts you used : ";
cin >> mins;
if ( mins == 450 || mins < 450 )
{
cout << "Total amount due : $39.99" << endl;
}
else if ( mins > 450 )
{
extramins = mins - 450;
extraCharges = extramins * 0.45;
dueAmount = 39.99 + extraCharges;
cout << "Total amount due : $" << dueAmount << endl;
}
else
{
cout << "ERROR!" << endl;
}
break;
case 'B':
case 'b':
cout << "How many minuts you used : ";
cin >> mins;
if ( mins == 900 || mins < 900 )
{
cout << "Total amount due : $59.99" << endl;
}
else if ( mins > 900 )
{
extramins = mins - 900;
extraCharges = extramins * 0.40;
dueAmount = 59.99 + extraCharges;
cout << "Total amount due : $" << dueAmount << endl;
}
else
{
cout << "ERROR!" << endl;
}
break;
case 'C':
case 'c':
cout << "How many minuts you used : ";
cin >> mins;
cout << "Total amount due : $69.99" << endl;
break;
default:
cout << "ERROR!" << endl;
break;
}
return 0;
}

/// Code by Asad Ali and officially posted on PADA Code

These lines of code first ask the user for choosing the package provided by Mobile Service Providers then it will ask for the used up mins. The according to the given charges it will output the total amount due. 
Share:

0 comments:

Post a Comment

Thanks for visiting my Blog.

Have any problem, feel free to contact us via Email: asadalipkp9@gmail.com

Have a nice day!

padacode.blogspot.com

Powered by Blogger.