In: Computer Science
You will be writing a program to calculate the cost of an online movie order.
Write a program that calculates and prints the cost of viewing something through the CNR Cable Company’s on demand. The company offers three levels of viewing: TV, Movies that are New Releases and Movies (not considered new releases). Its rates vary depending on what is to be viewed.
The rates are computed as follows:
TV: Free
New Releases: 6.99
Movies (not new releases): The cost is based on the year the movie was released before 1960: 2.99 1960 – 1979: 3.99 1980 – 1999: 4.99 after 2000: 5.99
Your program should prompt the user to enter the title of the item to be viewed (string) and a type of viewing code (type char). A type code of t or T means TV; a type code of n or N means new release; a type code of m or M means a non-new release Movie. Treat any other character as an error. Your program should output the title, type of viewing, and the amount due from the viewer, formatted neatly. When printing the type of viewing you must print the description (i.e. New Release) NOT the code (i.e. n). For the non-new release movies, the customer must give the year the movie was released. Therefore, to calculate the bill, you must ask the user to input the year. The program MUST utilize functions and MUST contain at least one if statement and at least one switch statement. Functions should be written for the following tasks: Output instructions Prompt for and accept the movie name Prompt for and accept the movie type (single character code) Calculate the charge Output the movie name, type description, and total charge
please please thumbs up!!!
hope it will help uh out!!!
Code::
(IN C++ PROGRAMMING LANGUAGE)
------------------------------------------------------
#include <iostream>
using namespace std;
double cost(int year)
{
double c;
if(year < 1960)
c = 2.99;
else if(year >=1960 && year <=1979)
c = 3.99;
else if(year >= 1980 && year <= 1999)
c = 4.99;
else if(year >= 2000)
c = 5.99;
return c;
}
int main() {
string title;
char code;
int year;
cout<<"Enter the title of the item to be viewed : ";
getline(cin,title); //to display the string in console
cout<<"\nEnter the Code of viewing : ";
cin>>code;
switch(code)
{
case 't':
case 'T': cout<<"\nTV : cost = $0";
break;
case 'n':
case 'N':cout<<"\nNew Releases : cost = $6.99";
break;
case 'm':
case 'M': cout<<"\nEnter the year of release : ";
cin>>year;
cout<<title;
cout<<"\nNot New Releases";
cout<<"\nCost $"<<cost(year); //function call
break;
default : cout<<"\nInvalid code ";
break;
}
return 0;
}
----------------------------------------------------------------
output::