NumberPower - Scanner in = new Scanner(System.in);

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
package lab04; p import java.util.Random; import java.util.Scanner; import java.math.*; public class NumberPower { p public static void main(String[] args) { int a = getNumber(); int b = getNumber(); System.out.println(a + " " + b + " " + Math.pow(a,b)); S } private static int getNumber(){
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Scanner in = new Scanner(System.in); System.out.println("Enter a number"); boolean num = in.hasNextInt(); if(num == false){ Random rad = new Random(); int generate = rad.nextInt(6); return generate; } else {int num1 = in.nextInt(); return num1;} r } }...
View Full Document

This note was uploaded on 09/20/2011 for the course COM SCI 227 taught by Professor Staff during the Spring '11 term at Iowa State.

Ask a homework question - tutors are online