r/learnjava • u/V1B3_GH0S7 • Nov 28 '19
Wondering if anyone could help with this
Write a program which uses a 1D array to store 10 temperature readings.
The user should indicate at the start of the program, what scale is being used when the data is being entered, either Celcius or Fahrenheit.
When the 10 temperatures are entered the program should proceed to convert C->F or F->C temperatures, whichever is the case in question and display the results using suitable output messages.
The program should uses 4 functions, main(), controller(), ctof() and ftoc(). The purpose of each of these functions is as follows:
Function Name: controller()
Object: Ask user for scale in which the data will be
entered, gets the 10 temperatures into the 1D
array. Calls either the ctof() or ftoc() function
passing a temperature to be converted. Prints
out the result sent back from the function in a
suitable format.
Function Name: ctof()
Object: Takes in a Celcius temperature and returns the
equivelant Fahrenheit temperature.
Function Name: ftoc()
Object: Takes in a Fahrenheit temperature and returns
the equivelant Celcius temperature.
Fahrenheit -> Celcius / 5 * 9 + 32
Celcius -> (Fahrenheit - 32 )/ 9 * 5
2
2
2
1
Nov 28 '19
Sounds like a lot in one go huh?
You have to make those methods yourself then call them in the main.
Once you figure out how to create an array, store 10 ints, and how to pull it from the array from a for loop then you'll be able to convert all 10 easily.
Good luck! :)
1
Nov 29 '19
Actually, it seems like the only 1 method is called in the main(), which is the controller(). The other 2 methods are called in the controller().
1
1
0
10
u/Dark-Nightmare Nov 28 '19
Seems pretty well explained, write your code and then when you’re stuck we can help guide you.