Please modify my code so that it works.
Q: Write an application that prints the following diamond shape. You may use outputstatements that…
A: Given: Write an application that prints the following diamond shape. You may use outputstatements…
Q: create a class that asks a user for 2 string inputs (USE The Java. Util. SCANNER) -compare…
A: write a Program in java on string operations given in problem statement
Q: Create a new class called Simplecalc. In this class, implement a program that asks the user to enter…
A: // Java program for simple calculator import java.io.*;import java.lang.*;import…
Q: s shown in the Figure. (Hint: A point is in the rectangle if its horizontal distance to (0, 0) is…
A: Analysis of the problem: There is a rectangle with vertices a,b,c,d(let). The position of the…
Q: Create a method which will accept a positive integer input and return a value according to the…
A: - The question is to create a method which will accept a positive integer input and return a value…
Q: A few years ago, 2048 was a popular game to download and play on the smartphone. You don't need to…
A: Array in java is a data structure that store similar value i.e. of same data type in a sequential…
Q: JavaScript Programming One day, Fred and his N friends were playing a card game in which each player…
A: Required: We have to write a code to maximize the sum which we get on the front cards, keeping in…
Q: Implement the design of the Student class so that the following output is produced: Driver Code…
A: In the question above, we are asked to create a class such that the Driver code gives the Output…
Q: Using the methods pickDir() and exractInt() as shown below, to write a simple automated game: how…
A: The program is written in java. MAXLOOPS is set to 20
Q: There is a children’s game called FizzBuzz where players take turns counting but replace the numbers…
A: public class FizzBuzz{ public static void main(String[] args) { int i; for(i = 1; i <= 100;…
Q: Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The…
A: Actually, the code has given below:
Q: Write a java program that helps the Lebanese scout to create an online tombola (lottery). Your…
A: Solution: Java program: import java.util.*; public class Main { // Main method public…
Q: Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The…
A: Actually, the code has given below:
Q: Write a simulation of T20 match. There are two teams, Team A and Team B. For every ball delivered…
A: Code : (In java) import java.util.*;class match{ public static void main(String[] args){ Random r =…
Q: Calculate keys in an object without using any loop in the previous question I had asked with loop.…
A: Required:- Calculate keys in an object without using any loop in the previous question I had asked…
Q: Write a simulation of T20 match. There are two teams, Team A and Team B. For every ball delivered…
A: import java.util.*;class T20 { public static void main(String[] args) { Random r = new…
Q: Implement the following class and invoke discountedPrice(): > Discountable discountedPrice (price:…
A: Objective: This program includes an interface and a class implementing the interface. The interface…
Q: Implement the design of the Laptop and Store classes so that the following code generates the…
A: Algorithm: Start Create a class Store with laptops a list as static variable and name as instance…
Q: A pentagonal number is defined as n(3n-1)/2 forn = 1 , 2 , …, and so on. Therefore, the first few…
A: Since, programming language is not mentioned in the question, we will answer this question in Java…
Q: using paintComponent(Graphics g) Write a program in java that, for four points A, B, C and P, •…
A: Explanation: Inside the findDistance method, find the distance by using the following formula:…
Q: Suppose you have been hired to develop a musical chair game. In this game there will be 7…
A: Program: Filename: Main.java import java.util.Scanner; import java.util.Random; /* Class…
Q: Solved in Java Write a method maxMagnitude() with two integer input parameters that returns…
A: The Answer start from step-2.
Q: Let's play a game of FizzBuzz! It works just like the popular childhood game "PopCorn", but with…
A: Answer the above program are as follows:
Q: U is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt()…
A: The program is written in java. MAXLOOPS is set to 20.
Q: Create a method that creates six random numbers between 10-20 which the method shall then return the…
A: I'm bound to provide the answer to only one of the given subparts. So, here is the answer to the…
Q: You are going to write a simulation for a mini survival game. In this game, one fly and three frogs…
A: You are going to write a simulation for a mini survival game. In this game, one fly and three frogs…
Q: Create a calculator using a class, the class must accept two values as parameters/arguments, then…
A: A class is a basically an blueprint of an object, and an object is an instance of class.
Q: Implement the design of the Pizza class so that the following output is produced: # Write your…
A: The Pizza class has four variables to store the data values for the object of the pizza. The three…
Q: Using the Pair0fDice class from PP 4.9, write a program that rolls a pair of dice 1000 times,…
A: The Program code that rolls a pair of dice 1000 times, counting number of box cars (two sixes) that…
Q: Lab Work 2 In this lab work, you will implement a coffee shop example. In this coffee shop,…
A: To create: To write a menu-driven C program for a coffee shop that asks the user the number of…
Q: Part 1: Make a new copy of the JavaFX program SimpleCalculator that you developed in Lab 11, then…
A: Find the answers to the questions below.
Q: Java Questions - (Has 2 Parts). Based on each code, which answer out of the choices "A,B,C,D,E" is…
A: Here we are creating an object of Date class Date dt = new Date(); Then we are calling get time()…
Q: A pentagonal number is defined as n(3n−1) ∕ 2 for n = 1, 2, . . ., etc.. Therefore, the first few…
A: //define a main class public class Pentagonal_Number { //define the main function…
Q: There is a garage where the access road can accommodate any number (specified by user) of trucks at…
A: Java program following using commands. On_road(truck_id); Enter_garage(truck_ id);…
Q: Write a complete method having the signature myfloor(double value) that can return mathematical…
A: Java Code : //importing package to read input from the user by using scanner classimport…
Q: Write a JAVA program that can be used to assign seats for a commercial airplane. The airplane has 13…
A: The required java code for given problem is given below- //Code begins import java.util.*;import…
Q: o Add another class for the Square and display its area, users must also input its values needed to…
A: For the Shape Square which is inherited from the interface Shape, we need to take input of a value…
Q: A regular polygon is an n-sided polygonin which all sides are of the same length and all angles have…
A: Program: //header file import java.util.Scanner; //definition of main class public class Main {…
Q: Write a program for a game that consists of two players. The rule of the game is that player 1…
A: For the above problem, I am going to provide a solution in python.
Q: Develop a letter-guessing game in this assignment. Requirements: 1). When the game begins, generate…
A: The java code is given below:
Q: In PYTHON use a Monte Carlo Simulation to write a code that gives the probability that in a…
A: For every play-through, we are re-initializing the frequency table to 0. Because through this we are…
Q: Write a program that reads a mile in a double valuefrom the console, converts it to kilometers, and…
A: Since you are not mentioning the programming language, here we are using C++ to complete the…
Q: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
A: Build a simple lottery program that asks the user to input six numbers, prints those numbers, spins…
Q: Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The…
A: Note: Below is the required program in the java language. Program Approach: Importing necessary…
Q: for the class ArrayAverage write a code that calculates the average of the listed numbers with a…
A: Note: As no specific programming language has been mentioned, Programming Language used: Java
Q: 2. Write a method that returns the ceiling of an input double. Note, this function always returns…
A: We have provided java code according to instructions provided with Utilities class and Tester class…
Q: A constructor that creates a regular polygon with the specified number of sides, length of side, and…
A: A constructor has the same name as the class. It is used to initialize objects as they are created.…
Q: You have a maze with obstacles and non-zero digits in it: 9+ 7 8 + 4 1 2 3 4 You can start from any…
A: The below code is PYTHON Code: import sys maxNum = -sys.maxsize -1rowNbr = [-1, 0, 0, 1] colNbr =…
Q: in Java eclipse ide Read from console a 2-digit integer number, save it in variable vz. Check this…
A: import java.util.Scanner; public class Main{ public static void main(String[] args) { Scanner…
Q: 5. Graphics The following is the screen capture of "rotating" a circle around a fixed point. Hint: Ꮎ…
A: I have mentioned java code in below ,please find in below
Build a simple guessing game where it will continuously ask the user to enter a number between 1 and 10. If the user's guesses matched, the user will score 10 points, and display the score. If the users' guess doesn’t match display the generated number. Also, if the user enters “q” then stop the game.
my code till now. Please modify my code so that it works.
import random
game(num)
if n=='q':
def game(n):
n= int(input("Enter a number between 1 and 10 "))
print("You entered:",n)
r = random.randint(1,10)
print("Random number is: ", r)
score=0
if n==r:
print("You won!")
print(" Your score: " ,score+10)
else:
print("You lost! Try again")
Trending now
This is a popular solution!
Step by step
Solved in 2 steps
- Using Java's card graphics, create a card game in which the dealer shuffles the deck and deals 13 cards to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat 4 times so all the cards are dealt eventually. Internally, the player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again."Use JAVA CARD GRAPHICS to create a card game in which the dealer shuffles the deck and deals 13 cards to the player. The player sorts her hand and says whether it includes the King of Hearts. Repeat 4 times so all the cards are dealt eventually. Internally, the player should return true or false without writing to the console. In response, the dealer should write on the console, "You won!" or "You loose again." Also create a unit test for the win and loose cases.This is my code for a random guess game and whoever has the shortest distance to number 21 wins the game. I need help with looping this game so that it would show these things:Numbers of hands played:Dealer Wins: Player Wins:and if the player randon guess is 21 the code would then exit and say thanks for playing. import random win = 21 dealer = 50 print('Player pick a number between 1-100') guess = random.randint(0,100) print('Player Guess:') print(guess) dealerdist = abs(dealer-win) playerdist = abs(guess-win) if (playerdist > dealerdist): print('Dealer Wins!') if (playerdist < dealerdist): print('Player Wins!')
- U is upward, D is downward, L is left and R is right : Using the methods pickDir() and exractInt() as shown below, to write a simple automated game: how long does it take a robot to travel from a left line of a field to the right line? Assume field is 15 units apart (meters, kilometers, it doesn’t matter), and the robot starts on the left line. pickDir(): // return string with random direction and random distance (within maxDist) public static String pickDir (int maxDist) { Random r = new Random(); // random number generator // return direction + distance return ( "" + "LRUD".charAt( r.nextInt(4) ) + (r.nextInt(maxDist) + 1) ); } extractInt(): // returns integer from string, from pos p1 to p2: str = "D1" – extractInt(str,1,1); public static int extractInt (String str, int p1, int p2) { return ( Integer.parseInt( str.substring(p1, p2+1) ) ); } Write the main() method that keeps looping until the robot’s random left…What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. The probability for a class of size 23, should be right around 50%. PLEASE use the code outline given below to answer this question: import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1 # Allow the user to determine class size:print("Please type in how many people are in the class: ")x= int(input()) success = 0 # Simulate:c = 0while(c < 10000) : # Step 1: re-initialize birthday frequency table (it must be re-initialized for each play-through (why?): k = 0 while(k < 365) : ft[k] = 0 k = k+1 # Step 2: randomly get x birthdays and update frequency table: k = 0 while(k < x): # your code…plz solve it asap ????????: Write a program for a game that consists of two players. The rule of the game is that player 1 inputs a random number from 1-100. Player 2 will input 5 numbers. If the summation of those numbers is equal to the number OR less than or greater than the number by 3 (+3 or -3), then player 2 wins. Otherwise, player 1 wins. Test Case 1 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 7 Output Player 2 wins Explanation: The summation of 10,10,20,5 and 7 is 52 which is greater than 50 by 2. According to the rule, player 2 wins. Test Case 2 Input Player 1, enter a number: 50 Player 2, enter a number: 10 Player 2, enter a number: 10 Player 2, enter a number: 20 Player 2, enter a number: 5 Player 2, enter a number: 1 Output Player 1 wins Explanation: The summation of 10,10,20,5 and 1 is 46 which is less than 50 and also doesn’t…
- Write a simple calculator which supports add subtract multiply and divide. Prompt the user for two numbers and an operation. Use number 1-4 for menu options. If divide is selected and the second number is zero, output an error message. If an invalid menu option is selected, output an error message. If all is well, perform the operation and output the result to one decimal. Please write in Java that results like test case examples. ThanksWrite a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 5.1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. 5.2. The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. Gather this input using JOptionPane.showInputDialog(). 5.3. Display the computer’s choice. 5.4. A winner is selected according to the following rules: If one player chooses rock and the other player chooses scissors, then rock wins. Display something to the effect of: “Rock smashes the scissors.” If one player chooses scissors and the other player chooses paper, then scissors wins. Display something like: “Scissors cuts paper.” If one player chooses paper and the other…Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 5.1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. Don’t display the computer’s choice yet. 5.2. The user enters his or her choice of “rock”, “paper”, or “scissors” at the keyboard. Gather this input using JOptionPane.showInputDialog(). 5.3. Display the computer’s choice. 5.4. A winner is selected according to the following rules: If one player chooses rock and the other player chooses scissors, then rock wins.Display something to the effect of: “Rock smashes the scissors.” If one player chooses scissors and the other player chooses paper, then scissors wins.Display something like: “Scissors cuts paper.” If one player chooses paper and the other player…
- What is the probability that in a classroom of x people, at least 2 will be born on the same day of the year (ignore leap year)? Use a Monte Carlo Simulation and a frequency table to write a program that calculates this probability, where the number of people (x) in the simulated class is given by the user. PLEASE USE the outline of the code GIVEN to answer this question: import mathimport random # create and initialize frequency table:ft = []k = 0while(k < 365) : ft.append(0) k = k+1 # Allow the user to determine class size:print("Please type in how many people are in the class: ")x= int(input()) success = 0 # Simulate:c = 0while(c < 10000) : # Step 1: re-initialize birthday frequency table (it must be re-initialized for each play-through (why?): k = 0 while(k < 365) : ft[k] = 0 k = k+1 # Step 2: randomly get x birthdays and update frequency table: k = 0 while(k < x): # your code goes here ########################## k = k+1 # Step 3:…The equation of a straight line is written as y = mx + b where m is the slope of the line and b is the value of y when x = 0. If there are two coordinate points of the line are given, then it is very easy to compute the line equation. Also you can find the distance between two points. Problem: Write a program to compute lines equation for a set of lines. The number of lines is read from the user. Each line is computed by generating two points randomly using Point2D API. In addition, distance between two points is computed. The program should display a table which include all information about each line. See sample runs below. Take into consideration: 1. Number of generated lines should be greater than zero. 2. Two point objects are constructed only once. Then just update the location of two points for each line using Point2D API methods. 3. x and y values of each point are generated randomly to be less than 100 and greater than 0. 4. Compute the distance between two points using…Modify songVerse to play "The Name Game" (OxfordDictionaries.com), by replacing "(Name)" with userName but without the first letter. Ex: If userName = "Kaitlin" and songVerse = "Banana-fana fo-f(Name)!", the program prints: Banana-fana fo-faitlin! Ex: If userName = "Kaitlin" and songVerse = "Fee fi mo-m(Name)", the program prints: Fee fi mo-maitlin Note: You may assume songVerse will always contain the substring "(Name)".