Question
Learning Objectives: Get familiar with the + - / * and % operators. Get Familiar with reading strings. Understand the use of variables in a
Learning Objectives:
- Get familiar with the + - / * and % operators.
- Get Familiar with reading strings.
- Understand the use of variables in a program.
- Understand how expressions are developed.
- Understand basic debugging strategies.
- Apply strategies learnt to more complex real-world problems.
For each part you MUST clearly indicate (comment) the beginning of the INPUT, PROCESSING and OUTPUT sections of your code.
Q1:
Write a program to request a students name and marks in 4 subjects. The program must print the name, total marks and average mark, appropriately labeled.
Q2:
Write a program to calculate electricity charges for a customer. The program requests a name, previous meter reading and current meter reading. The difference in the two readings gives the number of units of electricity used. The customer pays a fixed charge of $25 plus 20 cents for each unit used.
Print all the data, the number of units used and the amount the customer must pay, appropriately labelled
Q 3:
Modify part 2 so that the program requests the fixed charge and the rate per unit.
Q 4:
Write a program which, given a length in inches, converts it to yards, feet and inches. (1 yard = 3 feet, 1 foot = 12 inches). For example, given 100 inches, the program should print 2 yd 2 ft 4 in. Hint: use the mod operator.
Work with another person to create a program that satisfies the requirements of the program specified above.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started