Results 1 to 3 of 3
- 09-06-2011, 04:28 AM #1
Member
- Join Date
- Sep 2011
- Location
- Arizona
- Posts
- 1
- Rep Power
- 0
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.
Thanks in advance.
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
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 ); } } } }Last edited by p0intblankk; 09-06-2011 at 04:39 AM.
-
Re: For Loop For CSC110 Class..Need some help.
Please edit your post and change your quote tags to code tags so that your code will be readable.
I don't see above where you've attempted to solve number 3, nor where you ask a specific question about what you don't understand. Please do one or both so that we know how to help you.
- 09-06-2011, 04:39 AM #3
Similar Threads
-
Loop + inner class error
By snaquetime in forum New To JavaReplies: 4Last Post: 08-30-2011, 05:42 AM -
JTextField loop 2x for-loop WEIRD!
By Streetproject in forum AWT / SwingReplies: 2Last Post: 02-16-2011, 05:46 PM -
Convert do while loop to for loop
By sandeeptheviper in forum New To JavaReplies: 3Last Post: 01-03-2011, 12:37 PM -
Scanner class in my for loop
By Mode in forum New To JavaReplies: 1Last Post: 12-20-2010, 09:48 AM -
Purse Class ArrayList using for each loop for reverse, transfer method
By CEgan in forum New To JavaReplies: 0Last Post: 12-11-2009, 10:26 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks