I'm just wondering how I can make the program print results right after inputing a guess.

import java.util.Random;

public class Guess
{
	private int z;
	private int x;
	private int y;
	private int toss;
	public Guess(int a, int b, int c)
	{
		z = a;
		x = b;
		y = c;
	}
	public boolean GetGuess()
	{
		
		Random generator = new Random();
		int i;
		for(i = 0; i < 1; i++)
		{
			toss = generator.nextInt(6) + 1;
		}
		if(z == i)
		{
			System.out.println("correct");
		}
		else
		{
			System.out.println("Sorry please try again.");
		}
		if(x == i)
		{
			System.out.println("correct");
		}
		else
		{
			System.out.println("Sorry please try again.");
		}
		if(y == i)
		{
			System.out.println("correct");
		}
		else
		{
			System.out.println("Sorry you have failed.");
		}
		return true;
	}
}
import java.util.Scanner;
public class GuessTester
{
	public static void main(String[] args)
	{
	Scanner keyboard = new Scanner(System.in);
	System.out.println("Enter first guess");
	int x = keyboard.nextInt();
	System.out.println("Enter second guess");
	int y = keyboard.nextInt();
	System.out.println("Enter third guess");
	int z = keyboard.nextInt();
	
	Guess set1 = new Guess(x,y,z);
	
	System.out.println(set1.GetGuess());
	}
}

GetGuess returns a boolean value, so I'm guessing your println(set1.GetGuess()) statement in the main prints out only true or false. You could add a toString method and call that to print the results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.