Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago. Improve this question How would I get my program to quit when the user enters q? Is there something wrong with the scanner?
Tag: loops
How to Flip the triangle?
How to flip this triangle? So i was making aritmethic sequance triangle. It was upside down. How do I turn it 180 degree? for example: 1=1 1+2=3 1+2+3=6 etc… my code: Answer You can do it for any n, by getting input from the user
Trying to understanding Exit, Loop, Method and If and Else [JAVA]
Hello guys I need help with my code. I am trying to understand how to use the method, loop,if-else statement, and exit code. So I’m writing a simple calculation base on the user choice but right now I can’t figure out how to make the input read to loop back when user input else than the number (mean no alphabet
How do I recursively count up to less than n [closed]
I am struggling with the problem of having applications of loops and arrays. I have a variable “n” which represents the limit of the loop, i.e. if n = 3, the array would look like: arr[1,2,3,…
Skipping To The Next if Statement from Inside a for Loop
I’ve been learning some Java in my spare time and I’m a beginner, so I’m very sorry if I don’t understand some simple concepts. I’ve been trying to make a “Robot” move around an already made map. I’ve been trying to make lines of a text file into multiple arrays (ie. moving forward, turning left, turning right). Then, I’ve been
How I can make my program generate a new random number?
So I tried closing the window and reopening it afterwards so the whole program would start from the beginning. That didn’t work. Neither does Revalidating the frame (f.revalidate(), f.repaint()).. I’ve tried looping the if-functions with a while loop, setting the boolean to false when the number has been guessed. But that just resulted in an endless loop of testing if
how to properly check if a string is in txt file
I’m writing a program that manages a library. This part of the program is where you borrow a book, but only if it’s in the library, so I check if the book is in the library but it always comes back negative even if the string is in the library txt file. What should I do? Answer You are just
For loop is printing out multiple print statements
I’m making a program for class which prints out the number of vowels in a word and any help would be appreciated. Currently, the program prints out the correct number of vowels but also prints out the print statement, “vowels:” multiple times before. I’ve tried moving the print statement and the braces around but it says “error: ‘else if’ without
Rockpapergame with rounds and counter variables – java
I am creating a rock paper project which has the following requirement: Continually plays rounds of rock, paper, scissors until one of the players wins three rounds. At that point, the program outputs the winner and the number of rounds it took them to win. If there is no winner after 10 rounds, the competition is declared a tie Something
Java console printing out “infinity” infinite times instead of value?
I am trying to make a program that estimates pi with the Leibniz equation as an attribute to pi day, however instead of printing out the estimated pi value that I wanted the console is printing out “infinity” for infinite times until I terminate the execution. I am very very confused, help needed! code: I don’t think I divided anything