Starting from:

$34.99

COMP 1011 Lab 3- Jerry’s trade Solution

Laboratory Three: Basic Elements of C
Problem: Jerry’s trade
• Problem description
• Input & output requirements
The input begins with a line containing one non-negative integer M, representing the M pounds of cat of food Jerry prepared. Then 3 lines follow, each represents one of the 3 rooms in the warehouse and contains two non-negative integers J and F, respectively. All integers are less than 1000. The output is in a single line, with a float number to a precision of 3 decimal places, representing the maximum amount of cheese that Jerry can obtain.
• Sample results
Sample 1
5
7 2
4 3
5 2↲
The maximum amount of cheese is 13.333
Sample 2
20
25 18
24 15
15 10↲
The maximum amount of cheese is 31.500
• Tips:
a) Three steps: 1) understand the problem, 2) design an algorithm, and 3) implement.
b) Search “How to printf a float number to a precision of 3 decimal places” (e.g., 13.333,
31.500) ? a precision of 2 decimal places

More products