Question

Transcribed Image Text:12. My code currently produces the wrong answer (2). What would I have to change to get the right answer?
printf("Two goes into five this many times = %d\n",5/2);
SAVE
AI-Generated Solution
info
AI-generated content may present inaccurate or offensive content that does not represent bartleby’s views.
Unlock instant AI solutions
Tap the button
to generate a solution
to generate a solution
Click the button to generate
a solution
a solution
Knowledge Booster
Similar questions
- Is the following statement true or false? For every real number x, [x²] = [x]². If the statement is true, enter TRUE below; if it is false, enter a value for x that could be used for a counterexample.arrow_forwardUse the code posted below and create and console output that display the gallows every time a guess is made. def findOccurrences(s, ch): lst = [] for i in range(0, len(s)): if ch==s[i]: lst.append(i) return lst #hangman("chicken") n=int(input("Number of rounds of Hangman to be played:")) for i in range(0,n): if i<n: print("\nRound: ", i+1) word = input("Enter secret word: ") guesses = '' turns = int(input("Enter the number of failed attempts allowed:")) while turns > 0: failed = 0 for char in word: if char in guesses: print (char) else: print ("_"), failed = failed+1 if failed == 0: print ("Won!") break print guess = input("Guess a character:") guesses = guesses+guess if guess not…arrow_forwardPlease leave the fixed code and comments, thank you! 1. The following code should print out a random number between 1 and 10, why will it not function correctly? from random import randintprint (randint(10, 1)) 2. Why does the following code not return the expected value? def calcDiscountPrice(price, percentage): discount = price * percentage discountPrice = price - discount return discount 3. Why does the following code not return the expected value? def main():value = int(input("Enter number:"))tenPercent(value)print ("Ten percent is ", result)def tenPercent(num):return num * .1main()arrow_forward
- Chapter 5. PC #17. Rock, Paper, Scissors Game (page 317) Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows. 1. Add the following two lines to the beginning of your main method. This will allow your computer choices match with the test cases here in HyperGrade. long seed = Long.parseLong(args[0]); Random random = new Random(seed); 2. When the program begins, a random number in the range of 0 through 2 is generated. If the number is 0, then the computer has chosen rock. If the number is 1, then the computer has chosen paper. If the number is 2, then the computer has chosen scissors. (Do not display the computer choice yet.) 3. The user enters his or her choice of "rock", "paper", or "scissors" at the keyboard. You should use 1 for rock, 2 for paper, and 3 for scissors. Internally, you can store 0, 1, and 2 as the user choice, to match with the above schema. 4. Both user and computer choices…arrow_forwardHow do I write a game program that throws a die (singular for dice) until a certain number appears a given number of times in a row? A random die number can be generated with the following code: int diceFaceNumber = (int)((Math.random() * 6) + 1). There are two versions of the output. The first traces the program as it throws the dice and the other version just prints the number of throws it took. The game should first prompt the client for a die face number he would like to appear in a row. Then the program prompts the client for the number of times he would like that die face number to appear that many times in a row. The game then throws the die until that die face number appears that many times in a row. The game reports the number of throws it took to get that die face number to appear the requested number of times in a row. Allow the client to repeat the game as many times as she wishes. There are several methods that I can use: one public method that is invoked from the main, a…arrow_forwardFirst, write code that uses scnr.nextInt() to read in a value for numTomatoes from input. Then, write code that uses System.out.println() to output "My recipe needs ", the variable numTomatoes, and " tomatoes." Ex: If the input is 5, then the output is: My recipe needs 5 tomatoes. Ex: If the input is 3, then the output is: My recipe needs 3 tomatoes.arrow_forward
arrow_back_ios
arrow_forward_ios