+ 2

Hi, I need help, I keep getting errors, please help me find errors 🙏

https://code.sololearn.com/cXL3o3vLebXJ/?ref=app

14th Dec 2022, 3:52 PM
Janna Ariella Tabilog
Janna Ariella Tabilog - avatar
6 Respuestas
+ 3
Janna Ariella Tabilog , This is my take on your code, this code might help you int rn = (grade >= 1.00 && grade <= 2.75) ? 1 : (grade >= 2.76 && grade <= 3.99) ? 2 : (grade >= 4.00 && grade <= 5.99) ? 3 : 0; https://code.sololearn.com/c8Bdp3Qif2m9
14th Dec 2022, 4:37 PM
SoloProg
SoloProg - avatar
+ 4
static Scanner sc = new Scanner (System.in); here you are declaring it in method. static variables can only be declared class level. so remove static or declare outside methods. double grade = sc.nextDouble(); // switch case values must be integral type so use integer input.. replace with these lines : Scanner sc = new Scanner (System.in); int grade = sc.nextInt();
14th Dec 2022, 4:05 PM
Jayakrishna 🇮🇳
+ 2
SoloProg, Thank you! 🫶
14th Dec 2022, 4:39 PM
Janna Ariella Tabilog
Janna Ariella Tabilog - avatar
+ 1
changed it now, it suddenly always answers on default :')
14th Dec 2022, 4:33 PM
Janna Ariella Tabilog
Janna Ariella Tabilog - avatar
+ 1
Janna What does ? : 1 means solo learn never taught me that please your valuable reply is appreciated
15th Dec 2022, 6:17 PM
Rapheal Oluwabukola Rotimi (PRO)
Rapheal Oluwabukola Rotimi (PRO) - avatar
+ 1
Rapheal Oluwabukola , this is the explaniation of your question Use of the Question mark colon Operator in java The question mark and the colon operators, when used together, can be known as a ternary operator. It consists of three operands, and is therefore also known as a short-hand if...else operator. The only advantage it has that unlike multiple lines of code written in if...else statement, ternary operator can be written in a single line of code. The Question mark and colon operator is made up of three segments. The first segment is a boolean expression that returns either true or false. The second and third segments are the values that are assigned if the expression returns the boolean value true or false respectively. The second and third segments are separated by the use of a : sign. The question mark operator has the syntax as follows: var = condition ? value_if_true : value_if_false
16th Dec 2022, 10:35 AM
SoloProg
SoloProg - avatar