Notes
![]() ![]() Notes - notes.io |
Programmer: Caleb Cohen
Date: 2/28/17
Version: 1.1
Description: Prompts user with a list for mobile plans then calculates their cost and savings if there is any as well as telling them if they used more minutes that there are in the month.
*/
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
int main()
{
char choice; //Defining variables
int minutes; //Defining variables
double total; //Defining variables
double savings; //Defining variables
double limit; //Defining variables
string month; //Defining variables
cout << "Mobile Plans" << endl; //Displaying menu
cout << "Package A: $39.99 Per month for 450 minutes. Each additional minute is $0.45." << endl; //Displaying menu
cout << "Package B: $59.99 Per month for 900 minutes. Each additional minute is $0.40." << endl; //Displaying menu
cout << "Package C: $69.99 Per month with unlimited minutes." << endl; //Displaying menu
cout << "nWhat month is the package for? "; //Prompting for the month
cin >> month; //User enters month
//An unnecessary amount of if statements because I couldn't find a better way
if (month == "January")
limit = 44640;
else if (month == "january")
limit = 44640;
else if (month == "February")
limit = 40320;
else if (month == "february")
limit = 40320;
else if (month == "March")
limit = 44640;
else if (month == "march")
limit = 44640;
else if (month == "April")
limit = 43200;
else if (month == "april")
limit = 43200;
else if (month == "May")
limit = 44640;
else if (month == "may")
limit = 44640;
else if (month == "June")
limit = 43200;
else if (month == "june")
limit = 43200;
else if (month == "July")
limit = 44640;
else if (month == "july")
limit = 44640;
else if (month == "August")
limit = 44640;
else if (month == "august")
limit = 44640;
else if (month == "September")
limit = 43200;
else if (month == "september")
limit = 43200;
else if (month == "October")
limit = 44640;
else if (month == "october")
limit = 44640;
else if (month == "November")
limit = 43200;
else if (month == "november")
limit = 43200;
else if (month == "December")
limit = 44640;
else if (month == "december")
limit = 44640;
else
{
cout << "The month entered was not a correct month. The program is now ending." << endl; //Displaying the program ending
return 0; //Ending the program
}
cout << "nWhat package have you purchased? ";
cin >> choice; //User selection
switch (choice) //Switch statement
{
case 'A': //Case name
case 'a': //Case name
cout << "How many minutes have you used this month? "; //Prompting user for minutes
cin >> minutes; //User enters minutes
if (minutes > limit) //If statement to prevent the user entering more minutes than their are in a month
{
cout << "The minutes entered exceeds the value of the minutes in a month. The program is now ending." << endl; //Displaying the program ending
return 0; //Ending the program
}
if (minutes <= 450) //if statement for price
{
total = 39.99; //math for price
}
else
total = 39.99 + 0.45 * (minutes - 450); //Math for price
cout << "Your total for this month is $" << fixed << setprecision(2) << total << endl; //Output for price
if (total >= 59.99 && total <= 69.99) //If statement for savings with plan B
{
savings = total - 59.99; //Math for savings
cout << "If you chose package B, this month you would have saved $" << fixed << setprecision(2) << savings << endl; //Output for savings for plan B
}
if (total >= 69.99) //If statement for plan C
{
savings = total - 69.99; //Math for plan C
cout << "If you chose package C, this month you would have saved $" << fixed << setprecision(2) << savings << endl; //Output for savings for plan C
}
break;
case 'B': //Case name
case 'b': //Case name
cout << "How many minutes have you used this month? "; //Prompting user for minutes
cin >> minutes; //User enters minutes
if (minutes > limit) //If statement to prevent the user entering more minutes than their are in a month
{
cout << "The minutes entered exceeds the value of the minutes in a month. The program is now ending." << endl; //Displaying the program ending
return 0; //Ending the program
}
if (minutes <= 900) //If statement for price
{
total = 59.99; //Math for price
}
else
total = 59.99 + 0.40 * (minutes - 900); //Math for price
cout << "Your total for this month is $" << fixed << setprecision(2) << total << endl; //Output for price
if (total >= 69.99) //If statement for savings for plan C
{
savings = total - 69.99; //Math for plan C
cout << "If you chose package C, this month you would have saved $" << fixed << setprecision(2) << savings << endl; //Output for savings for plan C
}
break;
case 'C':
case 'c':
cout << "How many minutes have you used this month? "; //Prompting user for minutes
cin >> minutes; //User enters
if (minutes > limit) //If statement to prevent the user entering more minutes than their are in a month
{
cout << "The minutes entered exceeds the value of the minutes in a month. The program is now ending." << endl; //Displaying the program ending
return 0; //Ending the program
}
total = 69.99; //Math for price
cout << "You have unlimited minutes and your total for this month is $" << fixed << setprecision(2) << total << endl; //Output for price
break;
default:
cout << "Error! Selection was not on the list!" << endl; //Anything other than the three options ends the program
}
return 0;
}
![]() |
Notes is a web-based application for online taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000+ notes created and continuing...
With notes.io;
- * You can take a note from anywhere and any device with internet connection.
- * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
- * You can quickly share your contents without website, blog and e-mail.
- * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
- * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.
Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.
Easy: Notes.io doesn’t require installation. Just write and share note!
Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )
Free: Notes.io works for 14 years and has been free since the day it was started.
You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;
Email: [email protected]
Twitter: http://twitter.com/notesio
Instagram: http://instagram.com/notes.io
Facebook: http://facebook.com/notesio
Regards;
Notes.io Team