0% found this document useful (0 votes)
114 views

Java Lab

The document contains instructions for writing several Java programs: 1) A program that takes a first and last name as arguments and prints each on a new line. 2) A program that takes a grade as an argument, prints a comment based on the grade range using a switch statement. 3) A program that prints all odd numbers from 1 to 20 using a while loop. 4) A program that calculates total wages based on hours worked using different rates, taking hours as an argument. 5) A Student class with methods to set/get attributes like ID, name, marks, and calculate average, tested with multiple objects. 6) A program that reads exam results for 100
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
114 views

Java Lab

The document contains instructions for writing several Java programs: 1) A program that takes a first and last name as arguments and prints each on a new line. 2) A program that takes a grade as an argument, prints a comment based on the grade range using a switch statement. 3) A program that prints all odd numbers from 1 to 20 using a while loop. 4) A program that calculates total wages based on hours worked using different rates, taking hours as an argument. 5) A Student class with methods to set/get attributes like ID, name, marks, and calculate average, tested with multiple objects. 6) A program that reads exam results for 100
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Write a java program that takes your first name and last name as command line arguments to the

program and displays your name and last name on separate lines.

Write a program to take the students grade as an input argument and print the comments as follows
100 (Perfect Score), 90-100 (Excellent), 80-90 (Good), 70-80 (Above Average), 60-70 (Average) 50-60
(Below Average), 0-50 (Not Passing). Hint: use switch statement.

Write a program to print all odd numbers between 1 and 20. Note : Use while loop.

Write a program that calculates the total wages based on the number of hours worked. The wages are
calculated at a rate of 8.25 per hour for hours less than 40 and at the rate of 1.5 the standard rate for
any hours greater than 40. Number of hours is a command line argument to the program. Hint: Use
Integer.parseInt(String s) converts a string to an integer (To convert the number of hours from
command line to integer)

Write a Java class Student to meet the following specification. - The class should be able to support a 5
digit student ID, student name, marks for 3 subjects. You should have methods to set and get each of
the attributes, and calculate the average for the student. Write a tester program to test your class. You
should create 2 or 3 students and write code to test the class. Aim - Understand how to define a class
and create objects of the class.

The annual examination results of 100 students are tabulated as follows:

Roll No. Subject 1 Subject 2 Subject 3

Write a program to read the data and determine the following:

a) Total marks obtained by each student.

b) The highest marks in each subject and the Roll No. of the student who secured it.

c) The student who obtained the highest total marks.

Write a program that accepts a shopping list of five items from the command line and stores them in a
vector.

Write a Java applet program that draws a Pie Chart of Number of Students Registered in various
departments at 2nd year level within the University of Melbourne. Please access input that are passed
through PARAM statements in HTML. Hint: Each pie can be drawn using drawArc() or fillArc() method.

You might also like