You are on page 1of 5

CSC 185

Lab-10
Programs
• Write a program to delete all spaces from the
input String.
• Write a method to compare three numbers
and find the greatest and the smallest umber
in the given input numbers.
• Write a Java method to read an input String
and print the integer value of that String.
– Ex: Input String “1” should return integer ‘1’.
• In Java how do you represent the ‘Date’ and
‘Time’?
• Write a program that asks the user’s name and
then writes it back with the first name as entered
and second name all in capital letters. Assume
that there are two names and they are separated
by a single space character.
• Write a program where user enters a string and
the program echos it to the monitor/screen with
one character per line.
• Create a class ‘car’ and ad two methods:
– Boolean gasHog(): evaluates to true if the miles per gallon is
lower than 15.0
– Boolean economyCar(): evaluates to true if the miles pe gallon is
higher than 30.0
– Write a method calculateMPG() method. Each of the boolean
methods should use the calculateMPG() method to get the miles
per gallon.
– Sample run:
• Enter first reading: 10000
• Enter second reading: 10400
• Enter gallons: 10
• Miles per gallon:40
• Economy car!
• Write a Java program for :
We have 3 arrays namely int[] valA = { 13, -22, 82,
17}
Int[] valB = { -12, 24, -79, -13 }
Int[] sum = { 0, 0 , 0 , 0 }
Add the cell values of valA to valB and store the
result in cell value of sum.
Ex: for cell 0, 13 -12 = 1, So, the sum array
becomes
{1, 0, 0, 0}.

You might also like