When any of the first five numbers entered is less than 0 or greater 69 the user
ID: 3767798 • Letter: W
Question
When any of the first five numbers entered is less than 0 or greater 69 the user will receive a message to this effect and will be asked to reenter the number. You will create the code that will display one message when a number that is less than 1 is entered and a different message will display when the number entered is greater than 69. For example, if the user enters zero you might display the message: “The number must be greater than zero. Please reenter the number.”
If the number is the same as any number entered before it (with the exception of the Powerball number, which is the last number entered) the user will receive a message to this effect and will be requested to reenter the number. This is the same for the second through fifth numbers.
When entering the Powerball number, if the number entered IS NOT between 0 and 26, the user will receive a message to this effect and asked to reenter the number. One message will display if the number entered is less than 1, and a different message if the number entered is greater than 26.
The following MUST be included in the program:
• You must have multiple classes. One class must include the accessor/mutator methods, a readInput() method and a writeOutput() method. You will not use the mutator methods but I want you to include them within your code in order to demonstrate your knowledge of how to create them. Name this first program “Powerball.java”.
The values of the first five numbers must be saved within an array. The first element of the array will equal the first number entered, the second element of the array will equal the second number entered, etc. However, the number entered is not to be added to the array unless it is both unique from the other numbers entered, and it also falls within the correct range of numbers.
• The second program is to be named “PowerballTest.java” and will be responsible for creating a Powerball object and invoking the readInput() and writeOutput() methods located in the Powerball class.
Problems @ Javadoc eDeclaration Console 3 0 and less than 70 Number2 must be different from number1 Please enter number2 which should be 0 and less than 70 Please enter number3 which should be 0 and less than 70 Number3 must be different from numbers 1 and 2 Please enter number3 which should be >0 and less than 70 Please enter number4 which should be > 0 and less than 70 4 Please enter number5 which should be 0 and less than 70 70 Number5 must be less than 70 Please enter number5 which should be 0 and less than 70 Please enter a number that is > and less than 27 for your lucky powerball number 28 The powerball number must be less than 27 Please enter a number that is > 0 and less than 27 for your lucky powerball number 27 The powerball number must be less than 27 Please enter a number that is > and less than 27 for your lucky powerball number 26 Your powerball numbers are 1 2 3 4 5 and the Powerball numbers is 26Explanation / Answer
import java.util.Scanner;
class Powerball
{
Scanner scan = new Scanner(System.in);
int no1, no2, no3, no4, no5, no6;
int Num;
String readInput;
String writeOutput;
public Powerball()
{
no1 = 0;
no2 = 0;
no3 = 0;
no4 = 0;
no5 = 0;
no6 = 0;
}
public Powerball(int no1, int no2, int no3, int no4, int no5, int no6)
{
this.no1 = no1;
this.no2 = no2;
this.no3 = no3;
this.no4 = no4;
this.no5 = no5;
this.no6 = no6;
}
public int getNum()
{
return Num;
}
public void setNum(int no1, int no2, int no3, int no4, int no5, int no6)
{
this.Num = Num;
}
public String readInput()
{
return readInput;
}
public String writeOutput()
{
return writeOutput;
}
}
public class PowerballTest
{
public static void main(String[] args)
{
Powerball n1 = new Powerball(0,0,0,0,0,0);
Powerball n2 = new Powerball(0,0,0,0,0,0);
Powerball n3 = new Powerball(0,0,0,0,0,0);
Powerball n4 = new Powerball(0,0,0,0,0,0);
Powerball n5 = new Powerball(0,0,0,0,0,0);
Powerball n6 = new Powerball(0,0,0,0,0,0);
System.out.println("Please enter your number1 which should be > 0 and less than 70");
System.out.println("Number must be between 0 and 69");
System.out.println("Please enter your number2 which should be > 0 and less than 70");
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.