Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help implmenting the following Java Class This is what I have so far, but it is not correct so... package hmwk3; import java.util.Scanner; /**

Need help implmenting the following Java Class

This is what I have so far, but it is not correct so...

package hmwk3;

import java.util.Scanner;

/** * Write a program that takes three integers * from the command line and writes them in ascending order. * @author Darnesha Randle * */ public class PE04 { public static void main(String[] args) { // Create a new Scanner object Scanner input = new Scanner(System.in); // Prompt the user to enter 3 integers System.out.print("Enter three integers: "); int number1 = input.nextInt(); int number2 = input.nextInt(); int number3 = input.nextInt(); if (number1 > number2) { //swap number1 with number2 int temp = number1; number1 = number2; number2 = temp; if (number2 > number3) { //swap number2 with number3 int temp2 = number2; number2 = number3; number3 = temp2; } System.out.println(number1 + " " + number2 + " " + number3); } if (number1 < number2) { if (number2 > number3) { //swap number2 with number3 int temp3 = number2; number2 = number3; number3 = temp3; if (number2 < number1) { //swap number2 with number1 int temp4 = number2; number2 = number1; number2 = temp4; } } System.out.println(number1 + " " + number2 + " " + number3); } }

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Database 11g SQL

Authors: Jason Price

1st Edition

0071498508, 978-0071498500

More Books

Students also viewed these Databases questions

Question

1. How does Kiwi Experience maintain a continual customer focus?

Answered: 1 week ago