₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,013 members, 8,419,950 topics. Date: Thursday, 04 June 2026 at 08:10 AM

Toggle theme

Help Me Solve This Java - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingHelp Me Solve This Java (2759 Views)

1 Reply (Go Down)

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:
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
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:
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:
for(int i=33; i<70; i+=3){
System.out.print (" "+i);
};
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:
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);
why are you looping from 33, and not 30?
Re: Help Me Solve This Java by Nobody: 11:34am On Nov 06, 2015
Nairaface:
why are you looping from 33, and not 30?
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:
@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.
}
}
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=33
is 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.
1 Reply

Help Me Solve This Java Regex ProblemWhen Your Brain Throws Stackoverflow Error - Debug This JAVA Code If You CanPlease Solve This Java Problem.234

The 5 Types Of ProgrammersIntroductions To Form In HTMLBest Programming Language