I want help writing a flow chart for a program I wrote.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

I want help writing a flow chart for a program I wrote.

math game which generates two random numbers no greater than 50, then asks the user for the
division of them. The Game then keeps asking if they want to play until
they enter n. After that, the program prints the amount of wrong answers
and total questions.

import java.util.*;
public class MathGame {
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    //creates a new scanner object
    Random rand= new Random();
    String yes_or_no="yes";
    int wrong_answers=0;
    //reads and counts the wrong answers
    int total_answers=0;
    //reads and counts the total answers
    float user_answer=0;
    while (!yes_or_no.equals("n"))
    //the stopping condition is "n"
    {
       
        float n=rand.nextInt(50)+1;
        float m=rand.nextInt(50)+1;
        System.out.println("The First Random Number Is: "+n);
        //program prints a random number
        System.out.println("The Second Random Number Is: "+m);
        //progran prints another random number
        System.out.println("Divide Both Numbers Then State The Answer: ");
        //program asks the user to divide both numbers and input the answer
        user_answer=sc.nextFloat();
        //program reads and stores the answer
       
        if(user_answer!=(n/m)){
            System.out.println("Wrong Answer!");
            //if user inputted the wrong answer, program prints that its wrong
            System.out.println("The Correct Answer Was: "+(n/m));
            //program then reveals the correct answer
            wrong_answers=wrong_answers+1;
            total_answers=total_answers+1;
        }
        else{
            System.out.println("You Got It Correct!");
            //If user inputs the correct answer, program will print it is correct
            total_answers=total_answers+1;
        }
        System.out.println("Enter Y To Continue and N To Stop");
        //program tells user if they want to stop, enter N, if not, enter Y
        yes_or_no=sc.next();
        System.out.println(yes_or_no);
       
       
       
    }
    System.out.println("Wrong Answers: "+wrong_answers);
    //program prints the number of wrong answers the user had
    System.out.println("Total: "+total_answers);
    //program prints the total number of answers
}
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY