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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 21.06.2019 20:40, cmflores3245
Convert and simplify the following sentences to conjunctive normal form (cnf): (a) (p → (q → r)) → (p → (r → q)) (b) (p ∧ q) → (¬p ↔ q) (c) ((p → q) ∧ ¬q) → ¬p
Answers: 3
image
Computers and Technology, 22.06.2019 23:50, Crull5999
List a few alternative options and input and output over the standerd keyboard and monitor. explain their functioning in details.
Answers: 2
image
Computers and Technology, 23.06.2019 18:30, bsept1018
Report all segments of identity by descent longer than 20 polymorphisms between pairs of individuals in the following cohort of 15 individuals across 49 polymorphisms: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 numeric input 2 points possible (graded) you have 2 attempts to complete the assignment below. for example if the sequence is "bcd", which occurs in "abcdef" , the starting point would be 2 (b), and the finishing point would be 4(d). individuals 7,10 between positions
Answers: 1
image
Computers and Technology, 24.06.2019 00:20, talyku843
Describe a data structures that supports the stack push and pop operations and a third operation findmin, which returns the smallest element in the data structure, all in o(1) worst-case time.
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 in other subjects:

Konu
English, 10.11.2020 15:40
Konu
Mathematics, 10.11.2020 15:40
Konu
Mathematics, 10.11.2020 15:40