Question

In: Computer Science

You will be writing a program to calculate the cost of an online movie order. Write...

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

Solutions

Expert Solution

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::


Related Solutions

This week you will write a program that mimics an online shopping cart . You will...
This week you will write a program that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers for quantities -...
(Write a program in C++) A local instructor wants you to write a program to calculate...
(Write a program in C++) A local instructor wants you to write a program to calculate the average score made on exams by her students. For simplicity, she always has only 12 students in each course she teaches. She teaches multiple subjects so she would like to enter the name of the exam. She wants the program to also determine the highest and lowest scores and the number of students who passed and failed the exam. A score of 60...
Write a program that will calculate and display the cost of a gasoline purchase based on...
Write a program that will calculate and display the cost of a gasoline purchase based on the brand of gasoline, the octane rating and the amount purchased. Your program should first display a menu prompting the user for the brand of gasoline.  Next prompt the user for the amount of gasoline in liters. Finally, your program should calculate and display the cost of the gasoline purchase using the formula below. Cost of Discount Gasoline = ($2.49 - (100 - Octane Rating)...
write this program in java... don't forget to put comments. You are writing code for a...
write this program in java... don't forget to put comments. You are writing code for a calendar app, and need to determine the end time of a meeting. Write a method that takes a String for a time in H:MM or HH:MM format (the program must accept times that look like 9:21, 10:52, and 09:35) and prints the time 25 minutes later. For example, if the user enters 9:21 the method should output 9:46 and if the user enters 10:52...
Python This week you will write a program in Python that mimics an online shopping cart...
Python This week you will write a program in Python that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
Python This week you will write a program in Pyhton that mimics an online shopping cart...
Python This week you will write a program in Pyhton that mimics an online shopping cart . You will use all the programming techniques we have learned thus far this semester, including if statements, loops, lists and functions. It should include all of the following: The basics - Add items to a cart until the user says "done" and then print out a list of items in the cart and a total price. - Ensure the user types in numbers...
write a report about travel agency in c++ not a program writing just report writing
write a report about travel agency in c++ not a program writing just report writing
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
For this lab, you will write a C++ program that will calculate the matrix inverse of...
For this lab, you will write a C++ program that will calculate the matrix inverse of a matrix no bigger than 10x10. I will guarantee that the matrix will be invertible and that you will not have a divide by 0 problem. For this program, you are required to use the modified Gaussian elimination algorithm. Your program should ask for the size (number of rows only) of a matrix. It will then read the matrix, calculate the inverse, and print...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT