1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
#include <iostream>
#include <iomanip>
using namespace std;
string getMovieTitle();
char getCode();
double calcAmountOwed(string movieTitle,char code);
double calcTV();
double calcNew();
double calcNNew();
void printOutputs(double amountOwed, string moiveTitle,char code);
int main()
{
string movieTitle;
char code;
int movieYear;
double amountOwed;
getMovieTitle();
getCode();
calcAmountOwed(movieTitle, code);
calcTV();
calcNew();
calcNNew();
printOutputs(amountOwed, movieTitle, code);
}
string getMovieTitle()
{
string movieTitle;
cout<<"Please enter the title of the movie you would like to watch: ";
getline (cin, movieTitle);
return movieTitle;
}
char getCode()
{
char code;
cout<<"T = TV | N = New Releases | M = Non-New Release "<<endl;
cout<<"Please enter code (T, N or M): ";
cin>>code;
if(code != 't' && code != 'T' && code !='n' && code!='N' && code!='m' && code!='M')
{
cout<<"You must enter T, N or M!"<<endl;
getCode();
}
return code;
}
double calcAmountOwed(string movieTitle, char code)
{
double amountOwed;
switch(code)
{
case't': case'T': amountOwed = calcTV();
break;
case'n': case'N': amountOwed = calcNew();
break;
case'm': case'M': amountOwed = calcNNew();
break;
}
return amountOwed;
}
double calcTV()
{
double amount;
amount = 0.00;
return amount;
}
double calcNew()
{
double amount, days;
cout<<"How many days would you like to rent for? (1 or 2): "<<;
cin>>days;
if(days == 1)
{
amount = 6.99;
}
else
{
amount = 8.99;
}
return amount;
}
double calcNNew()
{
double amountOwed, movieYear;
cout<<"What year was the selected movie released?: "<<;
cin>>movieYear;
if(movieYear < 1960)
amountOwed = 2.99;
else if(movieYear <= 1979 && movieYear >= 1960)
amountOwed = 3.99;
else if(movieYear <= 1999 && movieYear >= 1980)
amountOwed = 4.99;
else if (movieYear >= 2000)
amountOwed = 5.99;
return amountOwed;
}
void printOutputs(double amountOwed, string movieTitle, char code)
{
cout<<"You have selected to watch: "<<movieTitle<<endl;
cout<<"Type of viewing: "<<code<<endl;
cout<<"Your total amount due is: "<<amountOwed<<endl;
}
|