fake edit: I've been trying to post it. Either this One Plus One or Windows 8.1 networking is fucking up. I had to log onto free wifi to post (out eating food).

Also there is a possessed old lady here and it's creeping me out.
The problem I have is the program doesn't fully encompass all parameters.
Run this program using parameters: [ A for plan A. Choose any month. 800 for the number of minutes used. ] Since the minutes are less that 900, the program should suggest Plan B. I need to take a step back I think and rethink things.
Code
// 17-NOV-2014
#include <iostream>
#include <iomanip>
#include <string>
void text1(), text2(char, int, float), calc3(int, float);
int calc1(int), switch1(), switch2();
float calc2(char, int);
int main()
{
std::cout << std::fixed << std::setw(3) << std::setprecision(2);
int planMonth, totalMinutes;
float bill;
char plan;
text1();
plan = switch1(); // Selected plan.
planMonth = switch2(); // The month of the bill cycle.
totalMinutes = calc1(planMonth); // Minutes used in bill cycle.
bill = calc2(plan, totalMinutes); // Total cost of bill.
text2(plan, totalMinutes, bill);
calc3(totalMinutes, bill);
return 0;
}
void text1()
{
std::cout << "You can use this program to determine if there is a more cost effective cell\nphone plan available. ";
std::cout << "The current plans available are as follow.\n\n";
std::cout << "\tPlan A - $39.99 per month; 450 minutes provided.\n\tAdditional minutes are $0.45 per minute.\n\n";
std::cout << "\tPlan B - $59.99 per month; 900 minutes provided.\n\tAdditional minutes are $0.40 per minute.\n\n";
std::cout << "\tPlan C - $69.00 per month; unlimited minutes provided.\n\n";
std::cout << "Now we will collect data from you regarding your usage.\n";
std::cout << "Please select the current plan you have by typing: A for plan A, B for plan B,\nand C for plan C, ";
std::cout << "followed by the 'enter/return' key.\n\n";
}
int switch1()
{
bool valid = true;
char planChoice;
do
{
char customerPlan;
std::cin >> customerPlan;
std::cout << "\nYou entered plan: " << customerPlan << std::endl << std::endl;
switch(customerPlan)
{
case 'a':
case 'A':
std::cout << "\tPlan A - $39.99 per month; 450 minutes provided.\n\tAdditional minutes are $0.45 per minute.\n\n";
planChoice = 'A';
valid = true;
break;
case 'b':
case 'B':
std::cout << "\tPlan B - $59.99 per month; 900 minutes provided.\n\tAdditional minutes are $0.40 per minute.\n\n";
planChoice = 'B';
valid = true;
break;
case 'c':
case 'C':
std::cout << "\tPlan C - $69.00 per month; unlimited minutes provided.\n\n";
planChoice = 'C';
valid = true;
break;
default:
std::cout << "INVALID INPUT!! Please select a correct plan: A, B, or C.\n";
valid = false;
break;
}
}
while (!valid);
return planChoice;
}
int switch2()
{
bool valid = true;
int month;
do
{
std::cout << "Please select the month of this bill cycle by entering the numerical month\n";
std::cout << "and pressing the return key.\n\n";
std::cout << "\t1 for January\n";
std::cout << "\t2 for February\n";
std::cout << "\t3 for March\n";
std::cout << "\t4 for April\n";
std::cout << "\t5 for May\n";
std::cout << "\t6 for June\n";
std::cout << "\t7 for July\n";
std::cout << "\t8 for August\n";
std::cout << "\t9 for September\n";
std::cout << "\t10 for October\n";
std::cout << "\t11 for November\n";
std::cout << "\t12 for December\n";
int mon;
std::cin >> mon;
switch(mon)
{
case 1:
std::cout << "\nJanuary\n";
month = 31;
valid = true;
break;
case 2:
std::cout << "\nFebruary\n";
month = 28;
valid = true;
break;
case 3:
std::cout << "\nMarch\n";
month = 31;
valid = true;
break;
case 4:
std::cout << "\nApril\n";
month = 30;
valid = true;
break;
case 5:
std::cout << "\nMay\n";
month = 31;
valid = true;
break;
case 6:
std::cout << "\nJune\n";
month = 30;
valid = true;
break;
case 7:
std::cout << "\nJuly\n";
month = 31;
valid = true;
break;
case 8:
std::cout << "\nAugust\n";
month = 31;
valid = true;
break;
case 9:
std::cout << "\nSeptember\n";
month = 30;
valid = true;
break;
case 10:
std::cout << "\nOctober\n";
month = 31;
valid = true;
break;
case 11:
std::cout << "\nNovember\n";
month = 30;
valid = true;
break;
case 12:
std::cout << "\nDecember\n";
month = 31;
valid = true;
break;
default:
std::cout << "\nINVALID INPUT!! Please select 1 - 12.\n";
valid = false;
break;
}
}
while(!valid);
return month;
}
int calc1(int month)
{
bool valid = true;
int billMinutes, monthMinutes, dayMinutes = 1440; // Number of minutes in a 24 hour day.
monthMinutes = (month * dayMinutes);
do
{
std::cout << "\nNow enter the total amount of minutes used during your previous months' bill.\n";
std::cin >> billMinutes;
if (billMinutes > monthMinutes || billMinutes < 0)
{
std::cout << "\nINVALID INPUT!! The maximum minutes for the month select is: " << monthMinutes << std::endl;
std::cout << "Please enter a value within the range of 0 through " << monthMinutes << "." <<std::endl;
valid = false;
}
else
{
valid = true;
}
}
while (!valid);
return billMinutes;
}
float calc2(char planLetter, int minutes)
{
int overageMinutes;
float totalFee, overageFee = 0;
if (planLetter == 'A')
{
if (minutes >= 451)
{
overageMinutes = (minutes - 450);
overageFee = (overageMinutes * 0.45);
}
totalFee = (overageFee + 39.99);
}
else if (planLetter == 'B')
{
if (minutes >= 901)
{
overageMinutes = (minutes - 900);
overageFee = (overageMinutes * 0.40);
}
totalFee = (overageFee + 59.99);
}
else if (planLetter == 'C')
{
totalFee = 69.00;
}
return totalFee;
}
void text2(char plan1, int totalMinutes1, float bill1)
{
std::string planString;
if (plan1 == 'A')
{
planString = "\nPlan A: \t$39.99 per month; 450 minutes provided. \n\t\tAdditional minutes are $0.45 per minute.\n";
}
else if (plan1 == 'B')
{
planString = "\nPlan B - $59.99 per month; 900 minutes provided.\nAdditional minutes are $0.40 per minute.\n";
}
else if (plan1 == 'C')
{
planString = "\nPlan C - $69.00 per month; unlimited minutes provided.\n";
}
std::cout << planString << "Minutes:\t" << totalMinutes1 << "\nBill:\t\t$" << bill1;
}
void calc3(int customerMinutes, float customerBill)
{
float planA = 39.99, planB = 59.99, planC = 69.00;
if (customerMinutes >= 451)
{
planA = (((customerMinutes - 450) * 0.45) + 39.99);
}
if (customerMinutes >= 901)
{
planB = (((customerMinutes - 900) * 0.40) + 59.99);
}
if (customerMinutes <= 461)
{
if (customerBill <= planA + 5)
//if (planA + 5 <= customerBill)
{
std::cout << "\n\nPlan A is a best value.\n";
std::cout << "Plan A price = " << planA << std::endl;
}
else
{
std::cout << "\n\nPlan B is a best value.\n";
std::cout << "Plan B price = " << planB << std::endl;
}
}
else if (customerMinutes >= 462 && customerMinutes <= 912)
{
if (customerBill <= planB + 5)
//if (planB + 5 <= customerBill)
{
std::cout << "\n\nPlan B is a best value.\n";
//std::cout << "Customer Bill = " << customerBill << std::endl;
//std::cout << "Plan B price = " << planB << std::endl;
}
else
{
std::cout << "\n\nPlan C is the best deal.\n";
//std::cout << "Customer Bill = " << customerBill << std::endl;
//std::cout << "Plan C price = " << planC << std::endl;
//std::cout << "Plan B price = " << planB << std::endl;
}
}
else if (customerMinutes >= 913)
{
std::cout << "\n\nPlan C is the best value.\n";
//std::cout << "Plan C price = " << planC <<std::endl;
}
}
This post was edited by NinjaSushi2 on Nov 24 2014 01:10am