Nested Loops: While Loop + For Loop
in
Programming Questions
•
1 year ago
So I recently started coding as part of my course curriculum, I lack quite a lot of experience with programs as a result am unsure about how to handle my current problem:
I'm working on a short Processing exercise that uses While Loops and For Loops with the intention to purposefully delay a calculation program, at least that's the half of it. The aim so far is to create a For Loop that runs a sqrt calculation a specified amount of times, in this instance a billion times (100,000,000). With the addition of a While Loop using a print function as part of the statement to print out a series of full stops. The final aim is to include the calculation loop INSIDE the forever while loop to delay the amount of times a full stop is printed. The end result should see a full stop being printed every half a second. Just to make sure I'm explaining myself clearly here are the actual instructions given:
- float c = sqrt(257);
- boolean always_true = true;
- //commented lines - print functions marking start and end
- //println("Starting calculations");
- //My attempt at nesting the for loop within the while loop, unsure as to how to actually do this with the desired effect :/
- while(always_true){
- for(c = 0; c < 1000; c++){
- print(".");
- }
- }
- //println("Finished Calculation");
N.B. I realise this is really mediocre but I really want to get this complete and help myself understand this. Desperately want to improve my coding abilities.
1