/* CSC15 Midterm Exam Review Guide Solutions to Practice Problems Practice Problems: YOU SHOULD WRITE OUT ON PAPER ALL FUNCTIONS FIRST. Remember, you'll be asked to write code on paper during the exam! Do not fool yourself. Write the program by looking at your notes and other programs first. Then, try to write it again, WITHOUT looking at your notes. 1. complete the following program, following instructions in comments: Write the following simple statements a. Declare integer variables x and y, int x; int y; b. Assign 2*x to y y = 2*x; b2. swap the values of x and y int temp; temp = x; x = y; y = temp; d. Write an if-else statement that determines which one of three integer variables (x,y,z) contains the smallest value. I'll write the solution as a function: public int least3(int x, int y, int z) { int answer; if (x speed2) && (RAM > ram2)) return true; else return false; } } // class PC public class revsol { public static void main(String[] args) { PC mypc; PC yourpc; mypc = new PC("pentium 4", 2.4, "Matrox"); yourpc = new PC("athlon", 2.0, "Radeon 8500"); mypc.upgrade(); yourpc.changegpu("Radeon 9500"); System.out.println("my pc has "+mypc.getram()+"megs of memory"); System.out.println("your pc has a "+yourpc.getdisk()+"gig drive"); if (mypc.betterthan(yourpc)) System.out.println("my pc is better than your pc"); else System.out.println("my pc is not better than your pc"); } }