Results 1 to 8 of 8
- 01-05-2012, 04:04 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
can someone help me answer this problem please?
Write a looping statement that will display the following output:
1.
4th Hello
6th Hello
8th Hello
10th Hello
2.
The sum of the first 10 integers is 55.
The average of the first 10 integers is 5.
3.
1 2 3 4 5
2 4 6 8 10
3 6 9 12 15
4 8 12 16 20
5 10 15 20 25
- 01-05-2012, 04:10 PM #2
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: can someone help me answer this problem please?
for the first problem i used this code:
for(int i=4; i<=10; i++);
if (i % 2 ==0)
System.out.print(i + ""th Hello");
but it's not working
- 01-05-2012, 04:11 PM #3
Re: can someone help me answer this problem please?
What exactly do you mean by "it's not working"? Do you see an Exception? Some strange behavior?
Hint: Where is the body of your for loop? Are you sure?How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-05-2012, 04:15 PM #4
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: can someone help me answer this problem please?
yes exception is shown..
uhmm sir? can you help me solve this problem please? i know it is very easy for you to answer this problem. All of that problem need to use looping like do while i guess.
- 01-05-2012, 04:17 PM #5
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: can someone help me answer this problem please?
i have also one problem here still not yet solve.. just need to insirt the correct loop in the blank:
import java.io.*;
public class Divisors2
{
public static void main(String [] args) throws IOException
{
BufferedReader r = new BufferedReader(new InputStreamReader (System.in));
int num;
String ans, div;
do{
div = _____;
System.out.print("Please enter an integer: ");
num = Integer.parseInt(r.readLine());
for (int i=1; _______; i++) {
if (_________)
div = ______________+ " ";
}
System.out.println("The proper divisor(s) of " +num+ " is/are: " + div);
System.out.print("Try Again? (yes/no): ");
ans = _________________;
System.out.println();
} while(________________________________);
}
}
and the output should be like this:
Please enter an integer: 5
The proper divisor(s) of 5 is/are: 1 5
Try Again? (yes/no): yes
Please enter an integer: 15
The proper divisor(s) of 15 is/are: 1 3 5 15
Try Again? (yes/no): yes
Please enter an integer: 25
The proper divisor(s) of 25 is/are: 1 5 25
Try Again? (yes/no): yes
Please enter an integer: 9
The proper divisor(s) of 9 is/are: 1 3 9
Try Again? (yes/no): no
Process completed.
- 01-05-2012, 04:20 PM #6
Re: can someone help me answer this problem please?
We can't just do your homework for you. I already gave you a hint. Where is your loop's body? Be especially mindful of misplaced semicolons.
How to Ask Questions the Smart Way
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
- 01-05-2012, 04:23 PM #7
Member
- Join Date
- Jan 2012
- Posts
- 16
- Rep Power
- 0
Re: can someone help me answer this problem please?
can you just give me example for divisors code sir please? :(
i haven't attended the class due to typhoon Washi hits our city(iligan city, philippines) that causes all our stuff and house destroyed by flash flood.
that is why i am looking for help in this forum.
- 01-05-2012, 05:43 PM #8
Moderator
- Join Date
- Apr 2009
- Posts
- 10,481
- Rep Power
- 16
Similar Threads
-
Compare true Answer /Player answer
By Eilime in forum New To JavaReplies: 1Last Post: 04-24-2011, 08:51 PM -
trivial string formatting problem that I just cannot find the answer to
By rippon in forum New To JavaReplies: 3Last Post: 02-27-2011, 12:03 AM -
Could anyway answer me this?
By Jojomofoman in forum New To JavaReplies: 14Last Post: 12-16-2010, 11:14 PM -
What is the answer to this strange problem:
By willemjav in forum New To JavaReplies: 5Last Post: 08-11-2008, 09:31 PM -
What is the answer yo my problem with this code
By masaka in forum New To JavaReplies: 4Last Post: 03-26-2008, 06:33 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks