Homework 2 Solution 2

# Java10points name cameronkroeker class cse292java hw2

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r the AccountTest I was able to write the withdrawal part where it will update account1 and 2 account2. I deserve 10 out of 10 because I was able to compile and run this java program after adding the code to be able to withdraw money from each account. Part 2: Palindrome.java &amp; PalindromeTest.java (10 points) /* Name: Cameron Kroeker Class: CSE292 Java Hw2: Palindrome.java Desc: Program tests for a palindrome */ import java.util.Scanner; public class Palindrome { public void checkPalindrome() // checks if a 5­digit number is a palindrome { Scanner input = new Scanner( System.in ); int number; // user input number int digit1; // first digit int digit1; // first digit int digit2; // second digit int digit4; // fourth digit int digit5; // fifth digit int digits; // number of digits in input number = 0; digits = 0; System.out.print(&quot;Please enter a 5 digit number to test the Palindrome: &quot;); number = input.nextInt(); while (number &lt; 10000 || number &gt; 99999) { System.out.println(&quot;Incorrect input for Palindrome, please try again...&quot;); System.out.println( &quot;Enter five digit number to test the Palindrome: &quot; ); number = input.nextInt(); } digit1 = number / 10000; digit2 = number / 1000 % 10; digit4 = number % 10000 % 1000 % 100 / 10; digit5 = number % 10000 % 1000 % 100 % 10; if(digit1 == digit5) { if(digit2 == digit4) { 3 System.out.println(&quot;You solved for the Palindrome!&quot;); } } else { System.out.println(&quot;Palindrome not found! Try again to find the Palindrome!&quot;); } } } /* Name: Cameron Kroeker Class: CSE292 Java Hw 2: PalindromeTest.java Desc: Test application for class Palindrome */ public class PalindromeTest { public static void main( String args ) { Palindrome app...
View Full Document

Ask a homework question - tutors are online