Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a java following: import java.util.Scanner; // A casino class public class StockMarket { public static void main(String Args[]) { // four reference variables, trader1,

Create a java following:

import java.util.Scanner;

// A "casino" class

public class StockMarket { public static void main(String Args[]) {

// four reference variables, trader1, trader2, trader3, trader4,

// each of which references a new instance of an object of type Trader,

// created using the non-standard constructor

// set stock change percentage (stockChangePercentage) for each player (sample percentages)

// trader1 has stock change percentage of 0.61

// trader2 has stock change percentage of 0.19

// trader3 has stock change percentage of 0.81

// trader4 has stock change percentage of 0.42

// invoke the getTraderName and getStockChangePercentage methods

// for each Trader object, to retrieve that information, and print

// it to the screen

// create a variable, keyboard, of type Scanner, and set it

// equal to a new object of type Scanner, that "listens" to

// System.in // a while loop, with a "true" conditional while (true) {

// For each of the four traders, retrieve the trader's name, how much money hey/she spent,

// how much money he/she currently has, and the trader's net profit. Print that information

// to the screen. Look at the homework handout for sample output

// use a System.out.print statement to ask how much money each trader should bet.

// Then declare a variable dollarsSpend of type double, and set its value to the keyboard's

// keystroke (be sure to use keyboard.nextDouble()).

// If the user enters 0, then issue a break statement, so that the while loop terminates

// Else, invoke the tradeSomeMore method of each Trader, and pass it the variable dollarsSpend

}

}

}

image text in transcribed
image text in transcribed
image text in transcribed
AT&T 23:33 @ 100% Back Trader.java // Import the Random class import java.util. Random; // A Class that defines an object of type Trader public class Trader { 1/ fields; there are four of them, and each should be private: // // traderName of type String 11 stockChangePercentage of type double // dollarsSpent of type double // dollarsMade of type double // method: get StockChangePercentage, public // input: void // output: double // description: retrieves the value stockChangePercentage field // // method: set StockChangePercentage, public // input: percentage, which is of type double // output: void 1/ description: assign the field stockchangePercentage to percentage // // method: tradeSomeMore, public // input parameter: dollars, which is of type double // output: none W description (pseudocode): // 1) increment field dollarsSpent by input value dollars // 2) declare randomNumbers of be of type Random, and instantiate new random class 15 Dashboard Calendar To Do Notifications Inbox AT&T 23:33 @ 100% Back Trader.java 1/ 3) declare variable randomDouble of type double, and assign it the value output // by the method nextDouble() of randomNumbers // 4) if (randomDouble

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

What is meant by Career Planning and development ?

Answered: 1 week ago

Question

What are Fringe Benefits ? List out some.

Answered: 1 week ago

Question

What is the preferred personality?

Answered: 1 week ago

Question

What is the relationship between humans?

Answered: 1 week ago