Write a program that asks the user to enter two decimal


Computer science

Discussion Question

What is a function? What is the difference between the calling function and the called function? What is the scope of a variable? Why should you avoid using global variables?

Homework

There are two components to this homework.

Part 1

This assignment uses functions and conditional structures.

Write a program that asks the user to enter two decimal numbers. The program should display the larger of the two numbers. Use a function Max() to find the larger number. Max 0 should have two arguments, which are the numbers that the user input. Max 0 should return the larger of the two numbers.

Part 2

You will be writing a program using an array.

1. Bluebird Airlines has flights from Phoenix to six other cities in Arizona. The cities are referred to by number, 1 to 6.The price for a round-trip ticket to each of the cities is shown here.

City

1

2

3

4

5

6

Price

56.79

105.69

93.49

155.99

87.49

73.99

Write a program that computes the total price of tickets that a customer orders. The program should prompt the user for the number of the destination city and the number of tickets desired. If the user enters an invalid city number, the pro¬gram should display an error message and terminate. The program should display the total price of the ticket order. Use an array to store the ticket price table.

2. Rewrite the program of Programming Problem 1 so that it processes any number of ticket orders: The program also should continually prompt the user for a valid city number. When the user indicates that there are no more customers to process, the program should display the total number of tickets sold to each of the six cities, the total price of the tickets sold to each city, and the grand total of all the ticket prices. Use an array of accumulators to store the number of tickets sold to each city.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Write a program that asks the user to enter two decimal
Reference No:- TGS01532553

Now Priced at $50 (50% Discount)

Recommended (91%)

Rated (4.3/5)