QuestionQuestion

Transcribed TextTranscribed Text

In this assignment, you will create some simple programs in JAVA to get used to the language constructs that you learned last term, including IF statements, FOR loops and arrays. (1) Quiz Program Write a class called QuizProgram that simulates a quiz that helps a young child practice addition and subtraction. The program randomly computes 10 quiz questions which are either addition or subtraction questions in the form of N1 - N2 = ___ or N1 + N2 = ___, where the user types in the guessed answer to the math expression. N1 should be a number from 0 to 99 and N2 should be a number from 0 to N1. The decision to use an addition or subtraction operator in the question should be chosen randomly as well, with equal probability. If the user types in the correct answer, the program should say "You are correct!", otherwise it should print "Sorry, the correct answer is ___". After the 10 questions have been asked, the program should show the % of correct answers. Here is example output (colors added for emphasis only): What is the answer to 3 + 0 = 3 You are correct! What is the answer to 22 - 11 = 11 You are correct! What is the answer to 17 - 13 = 4 You are correct! What is the answer to 93 + 21 = 5 Sorry, the correct answer is 114 What is the answer to 70 + 12 = 82 You are correct! What is the answer to 88 - 43 = 12 Sorry, the correct answer is 45 What is the answer to 88 + 42 = 130 You are correct! What is the answer to 94 - 59 = 35 You are correct! What is the answer to 91 + 62 = 153 You are correct! What is the answer to 68 - 20 = 48 You are correct! You scored 80% on the quiz (2) Histogram Program Write a program called HistogramProgram that creates an array of 100 randomly-generated byte values ranging from 0 to 9. The program should then display a histogram showing (as a string of * characters) the number of times that a certain number was generated. The histogram should look like this (although results will vary each time that you run it)  0 |******* 1 |********* 2 |*************** 3 |******* 4 |****************** 5 |******* 6 |**************** 7 |***** 8 |**** 9 |************ (3) Image Program Write a program called ImageProgram that creates a 10 x 10 two-dimensional array of 100 randomly-generated booleans . The program should then display an image that is represented by the array showing (as a grid of ‘O’ or ‘.’. characters), where O is shown when the boolean is true and ‘.’ is shown otherwise. See here  Then, your program should determine and print the longest horizontal sequence of O characters as well as the longest vertical sequence of O characters by examining the two-dimensional array. Here is some sample output (although results will vary each time that you run it ... and the highlighting was only added for emphasis): OOOOO.O.O. OOO..OOO.O .OO.OOO..O OOO.OOO..O OOO..OOOO. OOOO...OOO ..O.OO..O. .OOOO..O.. OO.O.OOO.. .OOOOOO.O. The longest horizontal sequence is 6 The longest vertical sequence is 8

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

1. // Main method for program execution
    public static void main(String[] args) {
       Random r = new Random();
       Scanner s = new Scanner(System.in);
       int percent = 0;
       for (int i = 0; i < 10; i++) {
            int N1 = r.nextInt(100);
            int N2 = r.nextInt(N1+1);
            boolean addition = r.nextBoolean();
            System.out.print("What is the answer to "+N1);
            int answer = N1;
            if (addition) {
                System.out.print(" + ");
                answer += N2;
            } else {
                System.out.print(" - ");
                answer -= N2;
            }
            System.out.print(N2+" = ");
            int input = s.nextInt();
            if (input == answer) {
                System.out.println("You are correct!");
                percent += 10;...

By purchasing this solution you'll be able to access the following files:
Solution.zip.

50% discount

Hours
Minutes
Seconds
$45.00 $22.50
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