Homework 2 Solution 2

Java10points name cameronkroeker class cse292java hw2

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

View Full Document Right Arrow Icon
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 & 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("Please enter a 5 digit number to test the Palindrome: "); number = input.nextInt(); while (number < 10000 || number > 99999) { System.out.println("Incorrect input for Palindrome, please try again..."); System.out.println( "Enter five digit number to test the Palindrome: " ); 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("You solved for the Palindrome!"); } } else { System.out.println("Palindrome not found! Try again to find the Palindrome!"); } } } /* 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