Homework 3 4
Homework 3 4
Topics :
Conditions ( if-else , switch-case ).
Looping ( while , for , do-while ).
___________________________________________________________________________________
LAB Exercises :
Write a java program that reads three numbers from the user and print the largest one
?
Write a java program that reads number of the day within a week and print the name
of that day ? (using Switch).
Consider the following investment problem: You put $10,000 into a bank account that
earns 5 percent interest per year. How many years does it take for the account balance
to be double the original ? using
HW :
Write a java program that reads int number from user and check if this number is even
or odd ?
Write a program that reads an integer and prints whether it is negative, zero, or
positive ?
Write a java program to compute the tax as illustrated in the following table:
Write programs with loops that compute
a. The sum of all even numbers between 2 and 100 (inclusive).
b. The sum of all odd numbers between a and b (inclusive), where a and b are
inputs.
c. The sum of all odd digits of an input. (For example, if the input is 32677, the
sum would be 3 + 7 + 7 = 17.)
Write a program that reads a word and prints each character of the word on a
separate line. For example, if the user provides the input "Harry", the program prints :
H
A
R
R
Y
Write a java program that print all prime numbers from 1 to 100 ?