Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Read from File/write to output file Can only use For, While, Do-While loops. no Try statements or Catches. Current code trying to work with CISS

Read from File/write to output file

image text in transcribedimage text in transcribed

image text in transcribed

Can only use For, While, Do-While loops. no Try statements or Catches.

Current code trying to work with

image text in transcribedimage text in transcribed

CISS 110 Programming & Logic I Fall 2017 Project 1 Due Date: Sunday, November 12, 2017 Write a program called Budget. Name your file Budget.java This program will use nested loops to calculate whether an individual is over or under their budget each month. It will read data from an input file and write the results to an output file The outer loop will run as as long as there is more data in the file. This outer loop should be a while loop and use the Scanner method hasNext () to determine whether it should continue. Within the outer loop, acquire the month and the total budgeted for the month. The month will be the first line of each data set contained in the input file and it should be read and stored in a String variable The amount budgeted for the month will be the second line of each data set and it should be read and stored in a double variable Then, an inner loop will iterate six times, one per budget category. The six categories are: food, rent, utilities, clothing, entertainment, personal care. The file will contain the amount spent for each category, one amount per line. The program will keep track of the total amount spent. This running total will be stored in an accumulator variable. This variable will have to be initialized to zero outside the inner loop but inside the outer loop. The inner loop will be a for loop that will iterate six times, from 0 to 5. When the for loop has completed execution, the accumulator variable will contain the total expenses. After the inner loop completes, write the specified output to the output file: the month, the amount budgeted and the total amount spent (accumulated in the for loop) for the month. Then, calculate whether the user went over or under the budget for that month and write this data to the file The input file, the file you will read from, is called budgetInput.txt. Hard code the name of this input file in your program. The File and Scanner classes can be used to read from the file. You can assume this file exists. A sample file has been provided to you, but it will not be the file used to grade your project

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions