This is the instruction:
Write a program for a mail-order company. Name the class MailOrderWrite. The program uses a data-entry screen in which the user types an item number and a quantity. The valid item numbers and prices are as follows and should be displayed in the screen prompt:
Item Number Price ($)
101 4.59
103 29.95
107 36.50
125 49.99
When the user enters an item number, call the method that accepts the item number and checks the number to make sure that it is valid. The method should return a boolean value to indicate whether or not the item number is valid. If it is valid, write a record in the text file named mailOrder.txt that includes item number, quantity, price per item and total price. Each value for the record should be separated using a comma delimiter. Use a loop to repeat the execution of the data-entry process until the user wishes to exit the program.
I tried to pass my program to my teacher, unluckily she rejected it, scolded me and i ended up crying down in the hallway. She doesnt accept my program because the program i made doesnt follow the intructions especially with the return value is to be boolean.
I am afraid to post my code here because it is an exam and my classmate could see it and copy it...Sorry for that. I will just give details further about it.
I manage to repeat the execution of the data entry process using do while. I used FileWriter, BufferedReader and InputStreamReader to it (no problem with that). The user can enter the an item number and and that item number is stored in a text file.
The only problem i had is:
If the user inputs an item number, the number should be pass to another method to check if it is valid and i use the if statement in it.
Example:
int num = kb.readLine();
check(num);
public static int check (int num)
{}
What should i put inside the curly braces to return a boolean value?
As what i have remembered, a boolean value is a true or false right?
So, i have to check the num that the user inputs and i think i should use if statement right?
If i use the if statement then it must be like this:
if (num == 101)
{}
Another question comes to my mind, what statement should i put inside the curly braces? to have a boolean value.
Also, if the user inputs an item number then the price of each item the user inputs is also stored in the text file.
Any help will be appreciated. Thank you.
Write a program for a mail-order company. Name the class MailOrderWrite. The program uses a data-entry screen in which the user types an item number and a quantity. The valid item numbers and prices are as follows and should be displayed in the screen prompt:
Item Number Price ($)
101 4.59
103 29.95
107 36.50
125 49.99
When the user enters an item number, call the method that accepts the item number and checks the number to make sure that it is valid. The method should return a boolean value to indicate whether or not the item number is valid. If it is valid, write a record in the text file named mailOrder.txt that includes item number, quantity, price per item and total price. Each value for the record should be separated using a comma delimiter. Use a loop to repeat the execution of the data-entry process until the user wishes to exit the program.
I tried to pass my program to my teacher, unluckily she rejected it, scolded me and i ended up crying down in the hallway. She doesnt accept my program because the program i made doesnt follow the intructions especially with the return value is to be boolean.
I am afraid to post my code here because it is an exam and my classmate could see it and copy it...Sorry for that. I will just give details further about it.
I manage to repeat the execution of the data entry process using do while. I used FileWriter, BufferedReader and InputStreamReader to it (no problem with that). The user can enter the an item number and and that item number is stored in a text file.
The only problem i had is:
If the user inputs an item number, the number should be pass to another method to check if it is valid and i use the if statement in it.
Example:
int num = kb.readLine();
check(num);
public static int check (int num)
{}
What should i put inside the curly braces to return a boolean value?
As what i have remembered, a boolean value is a true or false right?
So, i have to check the num that the user inputs and i think i should use if statement right?
If i use the if statement then it must be like this:
if (num == 101)
{}
Another question comes to my mind, what statement should i put inside the curly braces? to have a boolean value.
Also, if the user inputs an item number then the price of each item the user inputs is also stored in the text file.
Any help will be appreciated. Thank you.
