Skip to content
Advertisement

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

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

Advertisement