- #1
obeying
- 8
- 0
A user types a word and a number on a single line. Read them into the provided variables. Then print: word_number. End with newline. Example output if user entered: Amy 5
Result should read as: Amy_5
import java.util.Scanner;
public class SpaceReplace {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userWord = "";
int userNum = 0;
/* Your solution goes here */
return;
}
}-----------------------------------------------------------------------------------------------------------------------------------------
What I have so far this is the code and the product I'm getting:
Am I missing a step in the codes? userNum is an int and not a String, could this be why my setup isn't working? Thank you to all who reply and assist.View attachment 5885
Result should read as: Amy_5
import java.util.Scanner;
public class SpaceReplace {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userWord = "";
int userNum = 0;
/* Your solution goes here */
return;
}
}-----------------------------------------------------------------------------------------------------------------------------------------
What I have so far this is the code and the product I'm getting:
Am I missing a step in the codes? userNum is an int and not a String, could this be why my setup isn't working? Thank you to all who reply and assist.View attachment 5885