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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!