Meaning and usage of the word "option" | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 4

Meaning and usage of the word "option"

Java/usage of options

2nd Dec 2019, 1:20 PM
Farrux To`laganov
Farrux To`laganov - avatar
20 Answers
+ 1
Your question is not clear and also it does not make sense.
2nd Dec 2019, 1:43 PM
Avinesh
Avinesh - avatar
+ 1
Where is it used in Java? Never heard of it.
2nd Dec 2019, 1:45 PM
Avinesh
Avinesh - avatar
+ 1
There is no keyword as "option" in Java and whatever you have watched in the video may be is a program where he might have declared a variable option. How are we the people on QA suppose to know what it means or what it does?
2nd Dec 2019, 1:52 PM
Avinesh
Avinesh - avatar
+ 1
Ok, soon
2nd Dec 2019, 2:55 PM
Farrux To`laganov
Farrux To`laganov - avatar
+ 1
That's all
2nd Dec 2019, 3:04 PM
Farrux To`laganov
Farrux To`laganov - avatar
+ 1
Farrux To`laganov Please see in your second reply, first line: char option = '\0'; And a few lines underneath: option = scanner.next.charAt(0); And also below that line: switch(option) { // more codes here } Can you see now what Avinesh meant when he said "he might have declared a variable option"?
2nd Dec 2019, 3:13 PM
Ipang
+ 1
Farrux To`laganov For the next time please save the code in your profile and share the code link instead. Especially if the code is big (like more than 15 lines). It is more comfortable for everyone to review a code rather than raw text like that. Hope you understand. Follow this guide so your next question can gain better responses 👍 https://www.sololearn.com/Discuss/333866/?ref=app https://www.sololearn.com/post/74857/?ref=app
2nd Dec 2019, 3:17 PM
Ipang
+ 1
Good a job, 10Q
2nd Dec 2019, 3:31 PM
Farrux To`laganov
Farrux To`laganov - avatar
+ 1
char option = '\0' option = scanner.next().charAt(0); option is a variable, not an element.
2nd Dec 2019, 4:21 PM
varFildom_
varFildom_ - avatar
0
Can you explain me when to use it
2nd Dec 2019, 1:44 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
I've faced with this while watching a video about making bank account
2nd Dec 2019, 1:47 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
Let's wait for others views
2nd Dec 2019, 2:07 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
I think this doubt can be solved if you can share the code with the people here, or at least a portion of the code where you saw that 'option' word is being used. I guess that would be the best way to clear up ambiguity in the question, and prevent misunderstanding Farrux To`laganov
2nd Dec 2019, 2:49 PM
Ipang
0
package project; import java.util.Scanner; public class teamproj { public static void main(String[] args) { // TODO Auto-generated method stub BankAccount obj1= new BankAccount("XYZ", "BA0001"); obj1.showMenu(); } } class BankAccount { int balance; int previousTransaction; String customerName; String customerID; BankAccount(String name, String ID) { customerName=name; customerID=ID; } void deposit(int amount) { if(amount !=0) { balance=balance+amount; previousTransaction=amount; } } void withdraw(int amount) { if(amount !=0) { balance=balance-amount; previousTransaction=-amount; } } void getPreviousTransaction() { if(previousTransaction>0) { System.out.println("Deposited: "+previousTransaction); } else if(previousTransaction<0) { System.out.println("Withdrawn: "+Math.abs(previousTransaction)); } else { System.out.println("No transaction occured"); } }
2nd Dec 2019, 3:02 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
void showMenu() { char option='\0'; Scanner scanner = new Scanner(System.in); System.out.println("Welcome "+customerName); System.out.println("Your ID "+customerID); System.out.println("\n"); System.out.println("A. Check Balance"); System.out.println("B.Deposit"); System.out.println("C.Withdrow"); System.out.println("D.Previous Transaction"); System.out.println("E.Exit"); do { System.out.println("============================================"); System.out.println("Enter an option"); System.out.println("============================================"); option = scanner.next().charAt(0); System.out.println("\n"); switch(option) { case 'A': System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.out.println("Balance"+balance); System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.out.println("\n"); break; case 'B': System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.
2nd Dec 2019, 3:02 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
case 'B': System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.out.println("Enter an amount to deposit: "); System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); int amount = scanner.nextInt(); deposit(amount); System.out.println("\n"); break; case 'C': System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.out.println("Enter an amount to withdraw"); System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); int amount2=scanner.nextInt(); withdraw(amount2); System.out.println("\n"); break; case 'D': System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); getPreviousTransaction(); System.out.println("- - - - - - - - - - - - - - - - - - - - - - - "); System.out.println("\n"); break; case 'E': System.out.println("***********************************************"); break; default: System.out.println("Invalid Option!!!. Pleease enter a
2nd Dec 2019, 3:03 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
System.out.println("Invalid Option!!!. Pleease enter again"); break; } } while(option !='E'); System.out.println("Thank you for using our services"); }}
2nd Dec 2019, 3:04 PM
Farrux To`laganov
Farrux To`laganov - avatar
0
Well char is variable and option is the name of the variable. Variables are containers for storing data values. All java variable must be identified with unique names. These unique names are called identifier. Identifier can be short name (like x and y) or more descriptive name (age, sum, totalValue) Note: it is recommended to use more descriptive name to create Maintainable and understandable code.
2nd Dec 2019, 9:24 PM
Naved
0
Option? In html Or what
3rd Dec 2019, 7:27 AM
Akintunde Taofeek
Akintunde Taofeek - avatar
0
It was in java, fortunately I understood
3rd Dec 2019, 8:30 AM
Farrux To`laganov
Farrux To`laganov - avatar