Skip to main content
Filter by
Sorted by
Tagged with
-1 votes
0 answers
37 views

I’m learning Java and testing basic input handling. I wrote the following simple program: import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner ...
Burak HINGE's user avatar
-2 votes
1 answer
90 views

Trying to convert a json string (like below) into a List<String> "{ "stringField": "abc", "listField": "[\"item1\", \"item2\", \"...
rand om's user avatar
0 votes
0 answers
75 views

I wrote some simple Java code to take input from the console (using Eclipse 2016 IDE) to assist with iterating through a text file and outputting a file in SWIFT MT940 statement structure. For the ...
GuzziTony's user avatar
-2 votes
1 answer
62 views

Code: import java.util.*; public class InputInJava { public static void main(String [] args){ Scanner sc = new Scanner(System.in); String name = sc.next(); String fName = ...
rahul kumar's user avatar
0 votes
0 answers
31 views

Hi I'm trying to learn java This a simple program that stores a patient's blood details, well in any case how can i keep the program accurate by means of returning an error message if the input was ...
Annika's user avatar
  • 1
1 vote
0 answers
17 views

I have a program that is supposed to read from a txt file, compute the necessary functions, then print to another file. I can't seem to find the inputmismatchexception. Any help would be greatly ...
Bethane's user avatar
  • 11
0 votes
0 answers
39 views

what is the problem with my code and why do I have the InputMismatchException error every time I type the name in the console ? Scanner sc = new Scanner(System.in); System.out.println("...
Vincent's user avatar
0 votes
1 answer
79 views

In the following code snippet, scanner is throwing InputMismatchException after I input the value for coach and press enter. However if I use coach=sc.next(); , no such exception is thrown. void ...
Programmer AHN's user avatar
0 votes
1 answer
33 views

I was given an exam, where I had to create a class and after that, I had to write two functions in which the input parameter is an object Array and took the values from user input. Below is the code ...
Vishal's user avatar
  • 23
1 vote
3 answers
91 views

I am writing a program where I need to check if a string (name) contains any whitespaces or not. Here's part of my program : public static void main() { Scanner sc = new Scanner(System....
Super Coder's user avatar
0 votes
1 answer
95 views

"Eclipse IDE for Java Developers (includes Incubating components) Version: 2023-03 (4.27.0)" Intro to Programming using Java Section 3.5.3 Sorry for the very long post. This is my first post ...
whiteTreaty's user avatar
0 votes
1 answer
2k views

I'm reading sql code from a zip file of text files, saving the query as a variable sql_query, and passing the variable into a spark dataframe like spark.sql('sql_query'). The query text I parse out ...
SunflowerParty's user avatar
0 votes
0 answers
50 views

Having successfully created a policy holder and writing the information to csv I try to run the program again using a do while loop but receive an inputmismatchexception after typing surname. Can ...
donkey_junior's user avatar
0 votes
1 answer
45 views

I tried something like this but public static void main(String[] args){ Scanner Inp = new Scanner(System.in); System.out.println("****Bread Store Inventory****"); System.out....
Thaelith's user avatar
0 votes
2 answers
303 views

The goal is to make code that can handle exceptions and keep going. I made a try/catch for typing string instead of numbers, but when I test it, it prints the catch output but then has these errors : ...
Sami Danielson's user avatar
0 votes
2 answers
692 views

My input is in this format: 1 2 3 4 5 6 Alice The array length is not known. I coded it this way: import java.util.*; public class Main { public static void main(String[] args) { List<...
lsr's user avatar
  • 354
-1 votes
2 answers
4k views

Given the MileageTrackerNode class, complete main() in the MileageTrackerLinkedList class to insert nodes into a linked list (using the insertAfter() method). The first user-input value is the number ...
Dawgbizkit83's user avatar
0 votes
1 answer
106 views

I'm a very beginner programmer, in my first year of college. Currently, I'm trying to write some Java code to have the user insert a pin number using a scanner, asking for a new input if the pin ...
RadiantAine's user avatar
0 votes
0 answers
19 views

I am getting the input mismatch exception error on my code. I am getting error at the Engine displacement line. Scanner scanner = new Scanner(System.in); Car[] arr; System.out.println(&...
Aishwary Singh's user avatar
0 votes
1 answer
75 views

I've found that if I use the try with resources feature java provides which will automatically close of resources, I then can't use a boolean flag (or recursion) to resolve an InputMismatchException ...
Cameron Grant's user avatar
0 votes
2 answers
31 views

I am a newbie with java and the class scanners. I have two Codes and I dont get the point why one of them throws a InputMismatchException. I look forward to the answers. Here both codes: 1st one with ...
InfinityLoop's user avatar
0 votes
2 answers
209 views

i wrote this code to control input so user cannot enter anything except integers but problem is that: when an Exception occures, the message in Exception block is continousely printed and never ends, ...
amir's user avatar
  • 3
0 votes
2 answers
388 views

The question is: Create a class person with attribute name, age and gender. Create an array of the person to hold 10 person instances. Display the information stored on the person instance in the ...
Lekh Raj Awasthi's user avatar
0 votes
2 answers
41 views

This code is working for the first scanner to accept ints but the second scanner throws a mismatch error. I cannot seem to find why it is doing this. Can anyone help me out? I have tried everything ...
Dan Perez's user avatar
0 votes
1 answer
34 views

Here is my problem I've been struggling with: I want the input to be in this form: 1 So I wrote the code like this. Unfortunately, it either gives me an InputMismatchException at line 6 or cannot ...
Tina's user avatar
  • 13
0 votes
1 answer
905 views

I really want to know if there is a way to only get the value from the method to an another method. Because in the main method the first method is already call out while the the second needed the ...
Lux Luciora's user avatar
2 votes
2 answers
398 views

Problem I was messing around with Java today, and bumped into something that I can't fix by myself. I'm trying to get a double value from scanner but always get this error: Exception in thread "...
Yashmerino's user avatar
0 votes
1 answer
679 views

I am new to Java and I want to solve a simple problem in java. In input I need to take an integer a and then a character c and then another integer b And print the output if the character is '+' then ...
CSE's user avatar
  • 73
0 votes
1 answer
70 views

I'm trying to read the highscores of a game from a txt file and put them into an array so that another section of the program can detect a high score. Earlier I had everything declared as Int and it ...
Guido's user avatar
  • 1
0 votes
1 answer
566 views

I'm still learning java so excuse my lack of skill here, any help is appreciated! I've been working on this java I/O project for school all day at this point and now I'm getting this input mismatch ...
catherinemallory's user avatar
0 votes
1 answer
616 views

I'm working on a project and I already finished it, I have really simple problem which makes me really confused. I'm trying to ask a user to enter a number from a menu and depending on that different ...
Infernalissss's user avatar
0 votes
1 answer
632 views

Program: import java.util.Scanner; public class JavaExercise1 { static int sum, num1, num2; static Scanner scan = new Scanner(System.in); public static void add(){ System.out....
Prithviraj Tagadinamani's user avatar
0 votes
4 answers
3k views

Im currently trying to build a code that prevents wrong user input (storing a char/string to a integer, e.g.) but Im not being able to make it to work... public static void main(String[] args) { ...
Agustin's user avatar
1 vote
1 answer
270 views

import java.util.*; import java.lang.*; import java.io.*; class Main { public static void main (String[] args) { Scanner sc=new Scanner(System.in); Servicecentre[] ab=new ...
HARINI M's user avatar
0 votes
1 answer
66 views

I'm trying to catch InputMismatch exceptions and display a message that tells me where the exception occurred and what type of input is required. I need this to loop until the correct input is entered....
timestopMachinist's user avatar
0 votes
1 answer
105 views

I want to put a try/catch around the input=scanner.nextInt to throw an InputMismatchException if a letter is entered, I keep getting an infinite loop. This is the code with the infinite loop. What ...
smcconville's user avatar
0 votes
1 answer
30 views

My InputMismatchException isn't working, as when I put in something like a double into the input, instead of the exception output message, it gives me: Exception in thread "main" java.lang....
gino's user avatar
  • 41
0 votes
1 answer
60 views

I am receiving a InputMismatchException java ShoppingTime Exception in thread "main" java.util.InputMismatchException at java.base/java.util.Scanner.throwFor(Scanner.java:939) at ...
Willy's user avatar
  • 87
-1 votes
1 answer
93 views

I'm trying to read a .adi file that has a line format of String, Int and Double. For example: Ford,Fusion,2010,85254,12855.58 For the code, I'm required to use a try-catch statement and the method ...
Havanna Ransom's user avatar
3 votes
4 answers
2k views

Below is my code public class ExceptionHandling { public static void main(String[] args) throws InputMismatchException{ Scanner sc = new Scanner(System.in); int a = 0; int ...
P Yoga Prudhvi's user avatar
0 votes
2 answers
989 views

I'm fairly new to programming and I'm having trouble with my program continuously looping when I try to handle a InputMisMatch exception. I have a menu which takes in user input and then uses a switch ...
U Kushi's user avatar
  • 17
3 votes
1 answer
1k views

When I input integer numbers like 5, 7, 14 etc. everything is ok. But when I enter for example 7.5 I get an error. Where is mistake? Exception in thread "main" java.util....
Bahram Afandi's user avatar
0 votes
2 answers
54 views

import java.util.Scanner; public class Messdaten { public static double temperaturInDurchschnitt(Scanner sc){ int year= 0, month= 0 , day= 0; String discription = ""; ...
Saad Belkhou's user avatar
0 votes
2 answers
60 views

import java.util.Scanner; import java.util.InputMismatchException; public class bank { public static void login() { double balance; try { boolean subtract; ...
codenaem's user avatar
-1 votes
1 answer
64 views

This is the code I am using for my program import java.util.*; import java.io.*; import java.util.ArrayList; /** * This program will read the information from the * txt file and will organize ...
Bashar Shabani's user avatar
0 votes
1 answer
268 views

I am trying to take input one by one and then trying to perform operations over them. Following my code. import java.util.Scanner; public class PlayerRoster { public static void main(...
holdthemayo7's user avatar
0 votes
1 answer
48 views

After the name, Charlie is printed out it throws the input mismatch exception and says I'm entering a string into the int scanner but it really is a number so why is it telling me it's a string? This ...
reyna's user avatar
  • 21
0 votes
1 answer
236 views

I have a game in java called "Scotland Yard". In backend it is coded with java and frontend is coded with angular. From the beginning the game contained enums as transportation types but ...
Mohammed's user avatar
  • 321
0 votes
1 answer
30 views

Good evening. I am trying to read doubles from a file and put them into a double array. The way I have approached this is to use a Scanner. This is my code public static void decryption(int n, int d) ...
Jesse Schultz's user avatar
0 votes
3 answers
870 views

I am just learning Java and I'm struggling with Exception handling. I am trying to write a quick program that takes some inputs and exports them converted into different units. I am using Scanner to ...
Jack27696's user avatar

1
2 3 4 5 6