Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, please help with this java assignment! I have all the instructions below with the needed methods. There are Requirments!!!! Please read them! Also there

Hello, please help with this java assignment! I have all the instructions below with the needed methods. There are Requirments!!!! Please read them! Also there is a output text underneat as well. So please look.Please do not use "Continue", "break", and with any loops please do not use any boolean statements. For example: while(true). Any other form is fine just not was I showed. Please if you can, please include whats in the two text files. Also I was helped before but it just needs a little more help. I have posted the code I have already below. Thank you!

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

Code I have already:

import java.io.*; import java.util.*; class PriceIsRight2 { public static void main(String[] args) { Test obj = new Object(); obj.start(); } public void start() { String []names = new String[20]; String []items = new String[20]; String []players = new String[4]; double []bids = new double[4]; String item, choice="yes"; double price=0; Scanner s = new Scanner(System.in); names = loadNames(); items = loadItems(); System.out.println("-----jGRASP exec: java PriceIsRight2 "); System.out.println("You are about to play price is right game"); while(countNames(names)>0) { players = selectPlayers(names); while(choice.equalsIgnoreCase("yes")) { displayPlayers(players); item = selectItem(items); for(int i=0;iobcount) {//checking whether the list has enough players to replace players = replacePlayers(names,players,bids,price); displayPlayers(players); } } else { System.out.println(" All of the bids were below the actual price same players will play again:" ); } System.out.println(" Do you want to keep playing: (Ex: yes)"); choice = s.nextLine(); } } } /*Function to count the names left in the list*/ public int countNames(String []names) { int c=0; for(int i=0;iprice) { // calculating the number of over bids c++; } } return c; //returing over bids count } /*Function to replace players in place of over bid players*/ public String [] replacePlayers(String []names, String []players, double []bids, double price) { for(int i=0;iprice) { //if a player's bid is higher than that of original price int flag = 0; System.out.println(players[i]); while(flag==0) { int c = 0; int pi = (int)(Math.random()*20); //generates number between 0 to 20 for(int k=0;kv && b[i] A sample output has been provided in the file called output.txt. Please make sure that you understand the rules of the game before writing your code. Problem: Write a program that plays the game "Price IS Right". Here is the pseudocode for the game While (people want to play) fill the array of items by reading from the text file fill the array of names by reading from the text file //some of your code While there are players left on the list //some of your code 4 people will be selected randomly from the list of the players, these four people must be remove from the list An item from the list of the items will be selected randomly. This item must be removed from the list of the items Each player is prompted to enter a bid The player with the closest bid to the actual price without going over will win. If the bids of all the players are less than or equal to the actual price Same players will play again A new item will be selected (this item must be removed from the list else If there are enough players left on the list All The selected players with the higher bid than the actual price will be Replaced If the numbers of the replace players is less than 4 New item must be selected Do you want to play again? A sample output has been provided in the file called output.txt. Please make sure that you understand the rules of the game before writing your code. Problem: Write a program that plays the game "Price IS Right". Here is the pseudocode for the game While (people want to play) fill the array of items by reading from the text file fill the array of names by reading from the text file //some of your code While there are players left on the list //some of your code 4 people will be selected randomly from the list of the players, these four people must be remove from the list An item from the list of the items will be selected randomly. This item must be removed from the list of the items Each player is prompted to enter a bid The player with the closest bid to the actual price without going over will win. If the bids of all the players are less than or equal to the actual price Same players will play again A new item will be selected (this item must be removed from the list else If there are enough players left on the list All The selected players with the higher bid than the actual price will be Replaced If the numbers of the replace players is less than 4 New item must be selected Do you want to play again

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

Recommended Textbook for

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions