Question
Need help getting passed error please! Recieveing error in zybook: Input an abbreviation: Exception in thread main java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at TextMsgAbbreviation.main(TextMsgAbbreviation.java:7)
Need help getting passed error please!
Recieveing error in zybook:
Input an abbreviation: Exception in thread "main" java.util.NoSuchElementException: No line found at java.util.Scanner.nextLine(Scanner.java:1540) at TextMsgAbbreviation.main(TextMsgAbbreviation.java:7)
code:
import java.util.Scanner;
//Class definition public class TextMsgAbbreviation {
//Main method public static void main(String[] args) {
//Scanner class object Scanner sc = new Scanner(System.in); //Storing Abbreviations in strings String BFF = "best friend forever"; String TMI = "too much information"; String IMHO = "in my humble opinion"; String IDK = "i don't know"; String LOL = "laughing out loud";
//Reading an abbreviation System.out.print("Input an abbreviation : "); String abbreviation = sc.nextLine(); //Comparing its value switch(abbreviation) { case "BFF": System.out.println(BFF); break; case "TMI": System.out.println(TMI); break; case "IMHO":System.out.println(IMHO); break; case "IDK": System.out.println(IDK); break; case "LOL": System.out.println(LOL); break; default: System.out.println("Unknown"); break; } } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started