Help Me Solve This Java - Programming - Nairaland
Nairaland Forum › Science/Technology › Programming › Help Me Solve This Java (2759 Views)
| Help Me Solve This Java by Awwal1st(op): 5:56pm On Feb 22, 2015 |
I was asked to write a java program that prints all the multiples of 3 between 30 and 70 using a.. while loop b... do...while loop c... for loop Thanks |
| Re: Help Me Solve This Java by Nobody: 6:24pm On Feb 22, 2015 |
next |
| Re: Help Me Solve This Java by Nobody: 6:26pm On Feb 22, 2015 |
while.. loop int i = 33; System.out.println(i); while(i<70){ System.out.print(" "+i); i += 3; } do....While Loop int i = 33; System.out.println(i); do{ System.out.print(" "+i); i += 3; }while(i<70); |
| Re: Help Me Solve This Java by Awwal1st(op): 9:57pm On Feb 22, 2015 |
Thanks brother.. what of for loop? |
| Re: Help Me Solve This Java by ahmmyreal(m): 1:23am On Feb 23, 2015 |
for(int i=33; i<70; i+=3){ System.out.print (" "+i); }; |
| Re: Help Me Solve This Java by hollyfat(m): 8:00am On Feb 25, 2015 |
What about making some decision? while.. loop int i = 33; System.out.println(i); while(i<70){ If(i % 3 ==0){ System.out.print(" "+i); }i ++; } do....While Loop int i = 33; System.out.println(i); do{ If(i % 3 ==0){ System.out.print(" "+i); }i ++; }while(i<70); For loop For(int i =33;i<=70){ If(i % 3 ==0){ system.out.println(i); } } |
| Re: Help Me Solve This Java by kaboninc(m): 1:54pm On Feb 25, 2015 |
Awwal1st:There is a reason it is called an ASSIGNMENT! Find out on your own, the features of the various loop structures. |
| Re: Help Me Solve This Java by Nobody: 10:36pm On Feb 26, 2015*. Modified: 12:18pm On Jun 15, 2023 |
n |
| Re: Help Me Solve This Java by striker07(m): 12:07am On Mar 23, 2015 |
There should not be semicolon after your closing brace ahmmyreal: |
| Re: Help Me Solve This Java by Emdee590(m): 3:16pm On Mar 24, 2015 |
Factorials are used frequently in probability problems. The factories of a positive integer n (written n! And pronounced "n factorial" ) is equal to the product of the positive integers from 1 to n. Write a program that read an integer number, evaluates and display its factorial . |
| Re: Help Me Solve This Java by Emdee590(m): 7:27pm On Mar 24, 2015 |
(1) Factorials are used frequently in probability problems. The factories of a positive integer n (written n! And pronounced "n factorial" ) is equal to the product of the positive integers from 1 to n. Write a program that read an integer number, evaluates and display its factorial . (2) Write a program that reads ten (10) positive integers values from user; calculate and print their Mean. Hints : Mean x bar = summation fx / n thanks as I would be very happy to get the answer . |
| Re: Help Me Solve This Java by Emdee590(m): 2:54pm On Mar 26, 2015 |
Nobody to give me clue ? |
| Re: Help Me Solve This Java by Nairaface: 6:56am On Apr 11, 2015 |
@OP: at least make some effort, and show where you are stuck. for (int i = 30; i <= 70; i++) { if (i%3 == 0) { // if the remainder of dividing i by 3 is 0, modulo operator... System.out.println(i); //then print i on a new line. } } |
| Re: Help Me Solve This Java by Nairaface: 6:57am On Apr 11, 2015 |
holmez:why are you looping from 33, and not 30? |
| Re: Help Me Solve This Java by Nobody: 11:34am On Nov 06, 2015 |
Nairaface:Its still the same, since he has already declared i=33 |
| Re: Help Me Solve This Java by Nobody: 11:38am On Nov 06, 2015 |
Nairaface:This looks like C, any why didnt you bring the comment to another line instead of enclosing in a bracket, anyway i don't know how to use java. |
| Re: Help Me Solve This Java by Nairaface: 7:54pm On Aug 20, 2017 |
Its still the same, since he has already declared i=33is it? Considering that the question said to print from 30? If it is, when would 30 ever be printed? |
| Re: Help Me Solve This Java by Nairaface: 7:59pm On Aug 20, 2017 |
This looks like C, any why didnt you bring the comment to another line instead of enclosing in a bracket, anyway i don't know how to use java.none of the two comments is enclosed in a bracket. Those are valid comment syntax, but you can write it anyhow you find to be more readable. In a case where it's a comment for a single line of code, the above is more commonly used. That is Java, not C. Most OOPs do look alike. |
Help Me Solve This Java Regex Problem • When Your Brain Throws Stackoverflow Error - Debug This JAVA Code If You Can • Please Solve This Java Problem. • 2 • 3 • 4
The 5 Types Of Programmers • Introductions To Form In HTML • Best Programming Language