University of Toronto - Fall 2001
Department of Computer Science

Assignment 3

Due: Friday October 5, 9:00 a.m. - No late assignments will be accepted

Five Java Programs

This assignment involves writing five unrelated Java programs. All five use class BufferedReader to read from standard input as described in class. We will be autotesting your programs. Our autotesting program will expect exactly the information specified here, no more, no less. You must follow the following rules: 

Electronically submit all five .java files by following the submission instructions for your campus.

Information about String methods charAt, toUpperCase and toLowerCase and Character methods toUpperCase and toLowerCase can be found in "The Java API: An Introduction for Students" and also online.

What you need to do

  1. Write a program in file P1.java that reads 3 Strings and then prints them in the opposite order, concatenated, all on one line.
  2. Write a program in file P2.java that reads 3 doubles and then prints the average of the first two on one line, followed by the average of the second two on the next line, followed by the average of all three on the last line.
  3. Write a program in file P3.java that reads 2 doubles and an int and then prints the sum of the doubles multiplied by the int.
  4. Write a program in file P4.java that reads four Strings and then prints the third letter of each all on one line with no spaces. The first and third letters of the output should be capitalized and the second and fourth should be in lower case. You may assume that each String has at least 3 letters.
  5. Write a program in file P5.java that works with file Counter.java from the assignments page on the course web site.  Your program will make two Counter objects and modify them according to four integers that it reads from input. The first two integers specify the starting value and increment amount for the first Counter. The third and fourth integers specify the starting value and increment amount for the second Counter

    After the Counters are created print the first Counter on one line and the second Counter on the next. Then increment the first Counter once and the second Counter twice. Then print the first Counter on one line and the second Counter on the next. 

    To print each Counter use System.out.println and call Counter's toString method to get the String representations of the ints. For example: System.out.println(c1.toString());