Here's what I want the program to do:
Say I get this input: dasda2h
I want the program to output dasdahhh. This is because there is a 2 before the char in its right, it's pretty simple.
The way I try to do this is to check the variable of type char to check if it's keeping an integer, and if so just print the next letter this number of times.
Now on the main problem, I have tried many options to input (system.in.read, stdin.read(), nextInt()) but no luck. I have also been playing with Integer.parseInt() without any luck too.
Here's the code:
import java.io.*;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Assign2 output = new Assign2();
InputStreamReader convert = new InputStreamReader(System.in);
BufferedReader stdin = new BufferedReader(convert);
Scanner scan = new Scanner(System.in);
char inp =' ', prev =' ', temp;
log("Gief: ");
try {
prev = inp ;
temp =(char) stdin.read();
// temp = (char) System.in.read();
inp = temp;
log("inp: "+inp+" temp: "+temp);
}
catch(IOException e) {}
boolean retVal = false;
try {
Integer.parseInt(eisodos);
retVal = true;
}
catch (NumberFormatException nFE) {}
}
public static void log(String message) {
System.out.println(message);
}


Sign In
Create Account


Back to top









