Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to make program but I don't know how to get these outputs

Status
Not open for further replies.

tony90210

Technical User
Apr 10, 2014
2
US
I have a product which has three sizes: 1 gal ($20), 5 gal ($30), and 10 gal ($35). So I need to make a Fortran program which prompts the following to a consumer:
*How many gallons are needed? (input)
I understand how to get it to prompt this, but I am confused on the following step:
*The program needs to give a combination of the sizes for the consumer to meet their gallon amount requirement.
For Example:
*(input)*How many gallons are needed? 26
....
*(output)*You can buy two 10 gallon containers, one 5 gallon container, and one 1 gallon container for a total price of $120 (USD)

Does this make sense? I understand this is an odd question, but it is part of my class-project and can't figure it out. If anyone has any suggestions (please be as clear and elementary as possible), it would be much appreciated.
 
if n is the number of gallons provided by the user, the output of the code must be computed as follows :

m1=n/10
n=n-10*m1
m2=n/5
m3=n-5*m2
write(*,*) m1,m2,m3


François Jacq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top