CSAP Last Assignment

CSAP Last Assignment - Patrick Rutherford Spring 2007 Last...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Computer Science and Programming Spring 2007 April 24, 2007 Last Assignment Final Exam Questions Document 1 1. Write a method called insertCoins for a PinballMachine class that prints the statement “Press Start to Play” if 50 or more cents has been inserted by the user. On the other hand; if the user inserts less than 50 cents print the statement “Insert More Coins”. Note: Closed Book Solution: public void insertCoins(int amountInserted); { if(amountInserted >= cost) { System.out.println("Press Start to Play ") } else { System.out.println("Insert More Coins " } } 2. Find and correct all errors in the following code. Note: Closed Book. Public void PrintSolution( ); { // Print out the problem // and its solution System.out.println("17 – x = 8") System.out.println("x = 9") } Solution: 1 public void print 2 Solution( ) 3 { /** * Print out the problem * and its solution 4 */ System.out.println("17 – x = 8"); 5 System.out.println("x = 9"); 6 } Errors: 1, 2. The P in public and print is supposed to be lowercased. 3. No semicolon after the parentheses
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 2

CSAP Last Assignment - Patrick Rutherford Spring 2007 Last...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online