[SOLVED] COMP1011 Lab 3-Jerry’s trade

25.00 $

Programming resource
Digital learning resource
Category:
✓ Practical programming resource
✓ Suitable for guided study and reference
✓ Tutor guidance available when needed

Description

5/5 - (1 vote)

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

Resource details

Understand the Task Before You Use the Resource

Review the requirements, identify the programming concepts involved, study the implementation and test your understanding with your own examples and modifications.