Cheap Chirps Is a Pet Store Specializing in Pet Birds

Total Page:16

File Type:pdf, Size:1020Kb

Cheap Chirps Is a Pet Store Specializing in Pet Birds

Lab 1 Problem 1. Use a nested loop to print out the following: ******** ******* ****** ***** **** *** ** * Problem 2. Comprehensive programming: (file I/O, if…else, for loop, output manipulators) Cheap Chirps is a pet store specializing in pet birds. The store needs a new inventory program and has hired you to develop the program. Write a C++ program that will:

1. Read an inventory list of birds from a data file called BIRD.txt. The file contains information on bird species in the store. There are four lines in the file. Each line of the file has type of bird (no larger than 20 characters), price of the bird, and the consumed food in pounds monthly. Use for loop to read the related information.

BIRD.txt MACAW 2,500.00 20 AMAZON 550.7515 COCKATIEL 123.50 2 PARAKEET 45.50 1

2. Your program will find if the bird is a large hookbill or a small hookbill (Large hookbills eat 15 or more pounds of food a month.) Use a character 'L' to represent a large hookbill and an 'S' to represent a small hookbill.

3. Your program will also calculate the average price of a bird and the average amount of food eaten in one month.

4. Print the output so that it is organized as below. Note the values for the averages are printed to two decimal places. All printing is done in the main function.

BIRD PRICE FOOD HOOKBILL ------MACAW 2500.00 20 L AMAZON 550.75 15 L COCKATIEL 123.50 2 S PARAKEET 45.50 1 S The average price is: 804.94 The average food is: 9.50

Recommended publications