subject

The goal of this project is to create a Food Diary. This diary should contain breakfast, lunch, dinner and Snacks that you consume during the day. The user should be able to enter their food items and save it as a csv file. The user should be able to keep appending to the file.

This is what I have so far but I'm not sure where to close my scanner:

import java. io. File;

import java. io. FileNotFoundException;

import java. io. PrintWriter;

import java. util. Scanner;

public class App {

public static void main(String[] args) throws FileNotFoundException {

PrintWriter pw = new PrintWriter(new File("test. csv"));

StringBuilder sb = new StringBuilder();

sb. append("Date");

sb. append(',');

sb. append("FoodTime");

sb. append(',');

sb. append("FoodItem");

sb. append(',');

sb. append("Calories");

sb. append('\n');

int exit;

do {

Scanner sc = new Scanner(System. in);

System. out. println("Date : ");

String Date = sc. next();

System. out. println("Meal Time: ");

String FoodTime = sc. next();

System. out. println("Food Item : ");

String FoodItem = sc. next();

System. out. println("Calories : ");

String Calories = sc. next();

sb. append(Date);

sb. append(',');

sb. append(FoodTime);

sb. append(',');

sb. append(FoodItem);

sb. append(',');

sb. append(Calories);

sb. append('\n');

pw. write(sb. toString());

System. out. println("Please enter 0 to exit, 1 to continue : ");

exit = sc. nextInt();

} while (exit != 0);

System. out. println("done!");

}

}

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 06:30
Selective incapacitation is a strategy to reduce prison population
Answers: 3
question
Computers and Technology, 22.06.2019 17:00
1. so if i wanted to build a linux server for web services(apache) with 1cpu and 2 gb of memory.-operating at 75% of memory capacity2. a windows server with 2 cpu/ 4gb memory- operating at 85% of memory capacity3. a storage server with 1 cpu/ 2gb memory- operating at 85% of memory capacityhow much memory do i have to add for each server.so that the utilization rate for both cpu and memory is at a baseline of 60%."the details for the cpu like its processor or the memory's speed isnt to be concerned" yeah i kept asking my teacher if he's even sure about the but the whole class seems to be confused and the project is due in 3 days..this is a virtualization project where i have to virtualize a typical server into an exsi hypervisor.
Answers: 2
question
Computers and Technology, 22.06.2019 19:20
How might the success of your campaign be affected if you haven’t carefully completed all field data or if you accidentally insert the wrong merge field in the document?
Answers: 2
question
Computers and Technology, 23.06.2019 14:00
Select the correct answer. a company is currently focusing on creating specific management goals for itself. which level of maturity is the company demonstrating under the sse_ccm framework? a. performed informally b. planned and tracked c. quantitatively controlled d. well-defined e. continuously improving
Answers: 2
You know the right answer?
The goal of this project is to create a Food Diary. This diary should contain breakfast, lunch, dinn...
Questions
question
Geography, 23.09.2020 19:01
question
Mathematics, 23.09.2020 19:01
question
Mathematics, 23.09.2020 19:01
Questions on the website: 13722367