d2jsp
Log InRegister
d2jsp Forums > Off-Topic > General Chat > Homework Help > Help With A Basic Java Assignment > Create A Program That Reads Solar Energy
Add Reply New Topic New Poll
Member
Posts: 2
Joined: Sep 6 2018
Gold: 0.00
Sep 6 2018 10:55am
Hi, I need help with a basic java assignment. The instructions are:

Create a program that reads solar energy production data for the last week from a file, gets
input for the cost of the system, and outputs production, savings, days to recoup cost and
years to recoup the cost.

Program should read in a file called “energyProduced.txt”. The contents of the file are
at the bottom of the requirements. The file should be a normal text file with no
special formatting. The file should be in the same directory as the program.
• Use a named constant for the cost of electricity at .085.
• Read in all data from the file. (refer to pages 102-103)
o Get input from the file and store production values for each in doubles.
• Get input for “Total system cost” in dollars and stored as an integer. Get input
on same line as prompt, see example.
• Output the following items per the sample below:
• Total Energy Produced in one week.
• Total Savings for one week (total production times cost for electricity)
• Total Savings per day (the average)
• Days to recoup the system cost (truncated)
o Use typecasting to integer to get rounded value
• Years to recoup the system cost (truncated)
o Use typecasting to integer to get rounded value
• Ensure columns are aligned, use escape characters to align columns.

Data for Text File (name it energyProduced.txt)
70.3
72.2
71.6
70.5
69.0
72.2
72.6
Member
Posts: 89
Joined: Aug 12 2018
Gold: 474.00
Sep 13 2018 02:18am
It usually helps to be more specific about where you're stuck. Can you write a java program that compiles and runs? Can you read a text file as a string? Can you parse a string as a double? Can you print things?

You could also post what you have, if you're still working on this.
Member
Posts: 64,656
Joined: Oct 25 2006
Gold: 260.11
Sep 13 2018 11:35am
Dumb assignment

It's called excel


JKJK I know it's an intro assignment

This post was edited by Thor123422 on Sep 13 2018 11:35am
Member
Posts: 18,865
Joined: Apr 5 2008
Gold: Locked
Warn: 80%
Sep 15 2018 05:21am
Ur mum gave me a basic assignment
Member
Posts: 11,849
Joined: Aug 24 2005
Gold: 4,113.84
Sep 16 2018 10:51am
If this is the class I think it is, I might actually still have it saved on my PC. I'll check in a little bit.

Oh wow, just saw original post date. Likely done already lol

This post was edited by sbc'soneandonly on Sep 16 2018 10:52am
Go Back To Homework Help Topic List
Add Reply New Topic New Poll