Connecting...

This is a quick preview of the lesson. For full access, please Log In or Sign up.
For more information, please see full course syllabus of Introduction to Java
For more information, please see full course syllabus of Introduction to Java
Introduction to Java Loops
Lecture Description
In this lesson, our instructor Tom Quayle goes through an introduction on loops. He starts by discussing repeating an action, the while loop, do loop and for loop. He then goes on to talk about enhanced for loop, nested while loops and nested for loops. H
Bookmark & Share
Embed
Share this knowledge with your friends!
Copy & Paste this embed code into your website’s HTML
Please ensure that your website editor is in text mode when you paste the code.(In Wordpress, the mode button is on the top right corner.)
×
Since this lesson is not free, only the preview will appear on your website.
- - Allow users to view the embedded video in full-size.
Next Lecture
Previous Lecture
0 answers
Post by Basit Khan on January 16, 2017
Dr. Quayle,
after attending the java loops, I had a following exercise to solve;
In one of the introductory courses in a university, passing students are assigned a final grade of the uppercase letter P or lowercase p while failing students are assigned the letter F or f. Write a Java program that asks the user to enter grades (P/p or F/f) for 30 students, then calculates and displays both percentages of the passing and failing students.
I tried to solve it but to be honest I struggle to apply the syntax and formula. My main issue is that after reading and listening to the lecture I'm not able to apply it to create a program, kindly Help!
thanks
Omair
1 answer
Fri Oct 2, 2015 12:25 AM
Post by Malik Hall on September 23, 2015
Hi Professor Quayle,
I saw an example in a textbook that I did not understand about loops. This example showed SENTINELs, DecimalFormat, Scanners, and the highlighted word new. Could you explain these to me please because I have a difficult time understanding these in class since my teacher uses SENTINELs and Scanners in his examples.
https://drive.google.com/file/d/0B4eQm5IOB_khdFRFQTVFTUlZaTQ/view?usp=sharing
1 answer
Tue Mar 11, 2014 12:19 AM
Post by Zelong Zhao on March 9, 2014
well, all of questions above are very cool.
I still cannot understand what means of "break" and "returen"
What should I do?
I am not a english native speaker, so which book should I read. PS: In my personal dictionary, "understand" means I know What is it && Why we need it.
For example, What is the logic form of Break and Returen? Why Java includes those.
I know those are big questions and even do not be included in AP Subscribes but I really want to try to know those.
It is honor to get your lessons.
1 answer
Tue Nov 19, 2013 12:03 AM
Post by Ashna Ayub on November 17, 2013
Professor Quayle,
I have been able understand how to write a for loop in terms of syntax, but I don't really understand how to read the code which is why I am stuck on this problem:
Consider the following array:
int[] a = { 1,2,3,4,5,4,3,2,1, 0 }
What is the value of total after the following loops complete? (by looking at the for loop)
int total = 0;
for (int i = 0; i < 10 ; i = i +2 ) {total = total + a[i]; }
Could you please explain how to find the total by looking at the loop?
1 answer
Sat Oct 13, 2012 10:11 AM
Post by William Gould on October 13, 2012
Dr Quayle,
I am doing an assignment that doesn't seem to be working and i wanted to ask if you could help me understand whats going on.
my assignment is to develop a new class called MathTasks and create a method called productFor, productWhile, and productDoWhile that has a strictly positive integer parameter n and computes and returns the product of all the integers from 1 to n (inclusive of n).
here is my code so far (its very messy so far because im brand new to coding)
public class MathTasks
{
public MathTasks()
{ }
public void productFor(int n) {
for (int i = 1; (1 > 0) && (i <= n); i++)
{
System.out.print (n * 1);
System.out.print ("n = " + n);
} }
public void productWhile(int n)
{
while ((1 > 0) && (i <= n)){
{
System.out.print (n * 1);
System.out.print ("n = " + n);
}
}
}
public void productDoWhile (int n) {
if (n > 0) {
}
do {
System.out.print(n * 1);
System.out.print("n = " + n); }
while ((1 > 0) && (i <= n));
} }
Could you help explain to me how this works and what i am doing wrong?
1 answer
Last reply by: Malik Hall
Fri Sep 18, 2015 10:09 PM
Post by Brad Cherry on September 17, 2012
I am currently doing something like this and I am just beginning to understand this but I am still a bit lost, I use JCreator java program and I go with my class and I am stressed out and over worked any way I can keep up we get homework every Monday and it is due the next Tuesday and we get more than a few programs to make and that for me is too much pressure since I have little java experience