This is a beginning Java course so simplicy and guidance is apprectiated. For th
ID: 3763273 • Letter: T
Question
This is a beginning Java course so simplicy and guidance is apprectiated.
For this assignment, you are to first use pseudocode to develop the logic and coding for two programs. In the first program you will enable the user to input ten inventory items. The user will input the name of each item, the price of each individual item and how many of each item are in stock. You will accept the data inside a loop. The dialog with the user when requesting the input should be appropriate and comprehensive. The data will be stored in a file.
The second program will output the contents of the file to the user's screen. The output will include appropriate labels for all of the data. You will output data using a loop. You will identify the file to be accessed using a graphic dialog box.
The two programs will be independent. By that, I mean that one program will not reference the other using objects or classes.
Explanation / Answer
Program#1
class item {
main(){
String name[10];
double price[10];
int size[10]; //We use 3 parallel arrays here
BufferedReader bf=new BufferedReader(new FileReader (abc.txt)); //For writing new Content Everytime you run
FileWriter f0 = null;
// here f passed to the arguments is a file object to which we write the content
File f=new File("file1.txt");
for i=1 to 10 do{
System.out(" Enter name, price and size of Item "+ i +" : ");
in=new Scanner(System.in);
String s1=in.nextLine();
System.input(name[i], price[i], size[i]);
f0.write(source + System.getProperty("line.separator"));
in.close();
}
}
}
Program#2
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.