QuestionQuestion

The following Java program must:

1. Print your name and Project 2 followed by a blank line.
2. Prompt the user to enter 3 integers and read the integers.
3. Prompt the user to enter a character and read the character.
4. Print the output according to the following:

If the character read is ____, output
‘a’ - Print the largest integer value read
‘b’ - Print how many of the integers are even
‘c’ - Print how many of the integers have the same value
not ‘a’, ‘b’ or - Print an error message describing the problem

5. Print “Program Complete”

Hint:
To read the character, get the input as a String and then get the first character out of the String.

Requirements:
1. Your program should run through only one time and use one set of input. There are no loops.
2. The character read must be tested the minimum number of times. This means that if the value is ‘a’, then it should not be tested for ‘b’, ‘c’, etc.
3. Do not use String comparison. You must test for a single character.
4. Format your output for readability. Include text, blanks, etc.
5. Use meaningful variables names. Avoid n1, n2, etc.
6. Put blanks around the variables and operators in the code just like words in a sentence.
7. Document your program at the beginning of the file with your name and a description of the problem.
8. Test your program with different inputs to make sure it works correctly.
9. If you are using an IDE other than TextPad, do not use a package. Comment it out if required.

Restrictions:
1. Use only the following type of statements.
a. sequence statements (declaration, assignment, input, output)
b. if-else statements
2. Do not use any other types of statements. Do not use the Math class.

Solution PreviewSolution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

import java.util.Scanner;

public class Project2 {

public static void main(String[] args)
{
Scanner input = new Scanner(System.in);
int one, two, three;
char in;
System.out.println("Name Project2\n");
System.out.print("Please enter in 3 integers: ");
one = input.nextInt();
two = input.nextInt();
three = input.nextInt();

System.out.print("Please enter in 1 character");
in = input.next().charAt(0);

if(in == 'a')
{
if(one > two && one > three)
System.out.println("Greatest integer = " + one);
else if(two > one && two > three)
System.out.println("Greatest integer = " + two);
else if(three >= two && three >= one)
System.out.println("Greatest integer = " + three);
}
else if(in == 'b')
{...
$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats