Sample Questions - I/O (5 days)

 

What comes out?

  1. System.out.println(6 + 8 / 4 - 3);
  2. System.out.println(12 / 5 * 2 + 3);
  3. System.out.println(12.0 / 5 * 2);
  4. System.out.println(7 + 4 % 3 + 8);
  5. System.out.println(6 / ( 4 % 2) + 3);
  6. System.out.println(9 + 4 - 2 * 3);
  7. System.out.println(6 % 4 * 7 % 3);
  8. System.out.println(4.0 / 2 * 3 / 5);
  9. System.out.println(83 / 7 + 2 * 5);
  10. System.out.println(7 * 2 / 5 + 3);

11. Write a program that will let you enter 3 prices and will then print out the total price of the items with sales tax included. (sales tax is 6%)

Sample Output :

 Enter 3 prices 134.56  123.45  98.76

Sales tax is 21.41

Total Cost is 378.18

 

12. Write a program that will let you enter total inches and will then print out the total feet and inches left over.

Sample Output :

 Enter total inches 62

You are 5 feet 2 inches

 

13. Write a program that will let you enter the length and width of a rectangle and will then print out the area and the perimeter

Sample Output :

 Enter length 8

Enter width 6

Perimeter is 28 and area is 48

 

14. Write a program that will let you  enter 3 numbers and will then print out the sum and the average.

15. Write a program that will let you enter the number of adults and the number of children and will then tell you the cost of the movie tickets. Adult tickets cost 8.50 and children are 5.00.

Sample Output :

 Enter number of adults 5

Enter number of children 3

Total cost is $57.50

16. Write a program that will let you enter hours worked and salary per hour and will then tell you your salary for the week.

17. Write a program that will let you enter the base and height of a triangle and will then print out the area.

18. Write a program that will let you enter the radius of a circle and will then print out the area and the circumference of the circle.

19. Write a program that will let you enter your yearly salary and will then print out your weekly salary.

20. Write a program that will let you enter a price and a discount rate and will then tell you the sales price.


HOME