Computer Programming Lab One (Java) 2026: Scanner Input, Variables and If/Switch Tasks | Griffith College
| Module | Computer Programming – Java |
| College | Griffith College |
| Assessment | Lab One worksheet (6% of continuous assessment) |
| Tools | Java, IntelliJ IDEA, package griffith, class LabOne.java |
| Deadline | 29 October 2026, 23:59 |
This Computer Programming Lab One brief introduces Java fundamentals through four console programs written in a single LabOne.java class. Students practise Scanner input, arithmetic with constants and Math methods, rounding output to two decimal places, and branching with if and switch statements, while following the module’s commenting and naming standards.
Assignment Instructions
This worksheet is to help you become familiar with the basics of:
- Variable assignment
- Scanner input
- Conditional statements
This worksheet is worth 6% of your CA. Submit before 23:59, 29/10/26.
- Create a project called CP_LabOne_number_name, with number being your student ID (e.g. CP_LabOne_1000323_Tom_Hanks).
- Add a package called griffith.
- Create a class called LabOne.java with your main method.
- Add all tasks in the one file, and add your student name and ID as a comment at the top of the file.
Task One (10 marks)
Write a program to get the volume and surface area of a ball.
- Ask a user to enter the diameter of a ball in cm.
- Print out the volume and surface area of the ball.
- Round your totals off to two decimal places.
Example: Enter the diameter of the ball in cm: 10 → The volume of the ball is: 523.6cm cubed; The surface area of the sphere is: 314.16cm squared.
Task Two (20 marks)
Write the code to test the properties of a race car.
- Ask the user to enter the mass (m) of a car, its initial velocity (u), acceleration (a) and the time taken to complete the track (t).
- Print out: the distance the car covered (d = u*t + 1/2*a*t²); the weight of the car (w = m*g), making gravity a constant; and the final velocity of the car (v = u + a*t).
Example: mass 1500 kg, initial velocity 10 m/s, acceleration 2 m/s², time 15 s → distance 375.0 metres; weight 14715.0 N; final velocity 40.0 m/s.
Task Three (25 marks)
Write a simple calculator program.
- Ask a user to enter an arithmetic command and two numbers (Commands: Add, Sub, Div – e.g. Add 1 4).
- Using a switch or if statements, print the result.
- For division, add a check for if the second number is 0.
- Check for any incorrect commands.
Examples: Add 6 7 → Result: 13.0; Sub 4 10 → Result: -6.0; Div 6 0 → Cannot divide by zero.
Task Four (25 marks)
Write a program to check for a fever.
- Ask a user to enter their age; anyone 12 or less is considered a child.
- Ask them to enter their temperature in Celsius.
- Using the table below, print out the appropriate temperature class using if statements or switch statements.
Get Expert Help with Java Lab One
Test each task with the sample inputs in the brief before you submit, then try edge cases: a diameter of 0, a divisor of 0, a misspelt command and ages of exactly 12 and 13. Declare gravity and other fixed values as uppercase constants to pick up the coding-standards marks.
Our university assignment help supports first-year computing modules, our assignment help in Dublin covers Griffith College students, and you can compare the Software Development 2 assignment brief.
- 5N1652 Intellectual Disability Studies Assignment 1: Investigating an ID and Person-Centred Planning in the Social Model | QQI Level 5
- LOGT9404 Main Assignment 2026-27: Digital Transformation, Efficient vs Effective Supply Chains | TU Dublin
- TU378 CA1 Supply Chain Process Research Brief 2026: Mapping an African Supply Chain | TU Dublin
- Developing Relational Expertise in FET 2026: EEDI Personal Reflection Assignment Brief for Further Education Practitioners
- SO6071 Community Development Mid-Term Assignment 2026: Five-Slide Presentation and 1,000-Word Paper | University of Limerick
Get Free Assignment Quotes
