Saturday, October 18, 2014

Input from different classes.
































































































































Hi Guys,
































































































































I am working on a program where I want the user to input mulitple classes.































































































































One int, and one String.































































































































Can this be done? if so, how?
































































































































I have a tried to get input from both, like in the code below:
































































































































































































Java Code:







































































































































import java.util.Scanner;

public class ForumFlowchart {
public static void main(String[]args){

//Creating scanner.
Scanner input = new Scanner(System.in);

//Get information about job
System.out.println("Type in Int");
int i1 = input.nextInt();
System.out.println("Type in String");
String s1 = input.nextLine();





































































































































This only lets me input my int, and I do not get the chance to put in my String.































































































































Java Code:







































































































































import java.util.Scanner;

public class ForumFlowchart {
public static void main(String[]args){

//Creating scanner.
Scanner input = new Scanner(System.in);
//Get information about job
System.out.println("Type in String");
String s1 = input.nextLine();
Int i1 = (int)s1;

System.out.println("Type in String again");
String s2 = input.Line();





































































































































































































































































If I keep my input in the same class, I get the error "Can not cast int to string".































































My question is, it is possible to get an input from both an Int and a String in the same program?
































































































































I appreciate all the help :)































































































































































































































































No comments:

Post a Comment