# For Loop For CSC110 Class..Need some help.

• 09-06-2011, 04:28 AM
p0intblankk
For Loop For CSC110 Class..Need some help.
Need help in finishing my program....I have questions one and two answered but I need to implement question number three into my program.
I've established the first table of the degrees and asking the user for input. What I don't understand is how to implement the second for loop into my program and prompt the user to put in values to raise by a power.
Any help on how to program question three of my assignment would be much appreciated.

Here's the detail on the assignment.
CSC110
In Class
Loops 1
1. Write a program that displays a temperature conversion chart on the screen as
follows:
Fahrenheit Celsius Absolute Value
0 -17.78 255.37
20 -6.67 266.48
40 4.44 277.59
... ...... ......
... ...... ......
300 148.89 422.04
-To convert temperatures written in Fahrenheit to Celsius you subtract 32, multiply
by 5 and then divide by 9. To convert Celsius to Absolute Value (Kelvin), you add
273.15
2. Alter the program for question 1 so that it prompts the user for the lowest and
highest Fahrenheit temperature wanted in the table, and also prompts the user
for the desired step size between rows of the table (the step size is 20 in question
1). The program should begin by explaining to the user what it does, and should
appropriately echo the user's input before printing the table.
3. Write a program which will raise any number x to a positive power n using a for
loop. You will be getting x from the user.

--------------------------------------… is what i have so far......Loop.java
Code:

```import java.util.Scanner; public class Looping { public static void main( String[] args ) { System.out.println("What is the lowest fahrenheit value you want in your table?"); int a; Scanner input= new Scanner(System.in); a= input.nextInt(); System.out.println("What is the highest fahrenheit value you want in your table?"); int m; m= input.nextInt(); System.out.println("What do you want the values to step by?"); int p; p= input.nextInt(); { System.out.println("Fahrenheit " + " Celsius " +" Absolute Value "); double y; double z; for(int i=a; i<=m;i+=p) { y=(((double)i-32)*5)/9; z=((y+273)); System.out.println(i+" "+ y +" "+ z ); } } } }```
• 09-06-2011, 04:37 AM
Fubarable
Re: For Loop For CSC110 Class..Need some help.