0% found this document useful (0 votes)
4 views2 pages

Grade10 Java Exercise

The document is an exercise for Grade 10 Java programming focused on variables, input, and arithmetic. It includes five questions that require students to write Java programs for tasks such as converting temperatures, calculating shopping costs, determining cookie boxes, averaging scores, and estimating fuel costs for a road trip. Each question is worth 10 marks and emphasizes proper variable declaration and user input using the Scanner class.

Uploaded by

jamand
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Grade10 Java Exercise

The document is an exercise for Grade 10 Java programming focused on variables, input, and arithmetic. It includes five questions that require students to write Java programs for tasks such as converting temperatures, calculating shopping costs, determining cookie boxes, averaging scores, and estimating fuel costs for a road trip. Each question is worth 10 marks and emphasizes proper variable declaration and user input using the Scanner class.

Uploaded by

jamand
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

GRADE 10 JAVA PROGRAMMING

Exercise: Variables, Input & Arithmetic

Instructions: Answer all 5 questions. Each question is worth 10 marks. Write your Java code in the
space provided. Remember to declare your variables correctly and use Scanner for user input.

Question 1 [10 marks] — Temperature Converter


Scenario: A user wants to convert a temperature from Celsius to Fahrenheit.
Task: Write a Java program that asks the user to enter a temperature in Celsius (as a
whole number). Calculate the temperature in Fahrenheit using the formula: F = (C * 9 / 5) +
32. Print the result.
Hint: Formula: F = (C * 9 / 5) + 32

Question 2 [10 marks] — Shopping Receipt


Scenario: A small shop wants a simple program to calculate the total cost of buying items.
Task: Write a program that asks the user for the price of one item (as a double) and how
many items they are buying (as an int). Calculate and display the total cost.
Hint: Use a double for price and an int for quantity.

Question 3 [10 marks] — Cookie Baker


Scenario: A baker sells cookies in boxes of 12. After baking, there are always some
leftover cookies that don't fill a complete box.
Task: Write a program that asks the user how many cookies were baked (as a whole
number). Calculate and print how many full boxes can be made, and how many cookies are
left over.
Hint: Use / for full boxes and % for leftovers.

Question 4 [10 marks] — Average Calculator


Scenario: A sports coach needs to calculate the average score of three players.
Task: Write a program that asks the user to enter three players' scores as whole numbers.
Calculate the average score and display it. Remember: average = (score1 + score2 +
score3) / 3.
Hint: Store the average in a double.
Question 5 [10 marks] — Road Trip Planner
Scenario: A driver wants to estimate fuel cost for a road trip.
Task: Write a program that asks the user: (1) the distance of the trip in km (int), (2) the car's
fuel efficiency in km per litre (int), and (3) the price of fuel per litre in rands (double).
Calculate and print how many litres are needed (distance / efficiency) and the total fuel cost.
Hint: Two steps: litres = distance / efficiency, then cost = litres * price.

You might also like