ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 02 May 2017 My Price 8.00

import java.util.Random

import java.util.Random;

 

public class Main {

 

public static void main(String[] args) {

Random random = new Random(1000);

 

CalculatorInterface calc = new CalculatorImpl();

 

System.out.println("Answer 1: " + calc.equal()); // Print the initial

// value stored in

// calc should return 0

 

// Test calc class 

for (int i = 0; i < 26; i++) {

// Get a random integer to select one of the four methods

int r = random.nextInt(4);

// Test statement for what it is selecting

// System.out.println( "Int: " + r );

switch (r) {

case 0:

calc.plus(random.nextInt(10));

break;

case 1:

calc.minus(random.nextInt(10));

break;

case 2:

calc.slash(random.nextInt(10));

break;

case 3:

calc.star(random.nextInt(10));

break;

default:

 

}

 

}

 

// Should return -218.0

System.out.println("Answer 2: " + calc.equal());

 

// Reset/clear

calc.reset();

 

// Should now have 0 in the calc, print 0

System.out.println("Answer 3: " + calc.equal());

 

// Simple example

calc.plus(2);

calc.minus(1);

calc.star(5);

calc.slash(10);

// Should now have 0.5 in the calc, print 0.5

System.out.println("Answer 4: " + calc.equal());

 

}

 

}

Answers

(11)
Status NEW Posted 02 May 2017 06:05 AM My Price 8.00

-----------

Not Rated(0)