r/learnjava • • 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

1 Upvotes

9 comments sorted by

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.

2

u/Bunnymancer Nov 28 '19

And what is your question?

2

u/MyNameIsRichardCS54 Nov 28 '19

Sure, what have you done and where are you stuck?

2

u/gonzohst93 Nov 28 '19

Seems like ya got it all figured out already

1

u/[deleted] 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

u/[deleted] 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

u/[deleted] Nov 29 '19

You're right, good job. :)

1

u/[deleted] Nov 29 '19

Write a for loop.

The instructions are clearly worded.

0

u/[deleted] Nov 28 '19

[deleted]

1

u/toshels Nov 28 '19

Yeah, same.