write an expression that continues to bid until the user enters 'n'. java

Answers

Answer 1

Answer:

In java, Write an expression that continues to bid until the user enters 'n'.

import java.util.Random;

import java.util.Scanner;

public class AutoBidder {

public static void main (String [] args) {

Scanner scnr = new Scanner(System.in);

Random randGen = new Random();

char keepGoing = '-';

int nextBid = 0;

randGen.setSeed(5);

while (/* Your solution goes here */) {

nextBid = nextBid + (randGen.nextInt(10) + 1);

System.out.println("I'll bid $" + nextBid + "!");

System.out.print("Continue bidding? ");

keepGoing = scnr.next().charAt(0);

}

System.out.println("");

return;

}

}

Explanation:

Hope it's help you ;)

Answer 2

Java is a high-level programming language that has a concise syntax and is designed to be platform-independent. It is also a multi-paradigm programming language, which means that it supports a variety of programming styles, including object-oriented, imperative, and functional programming.

A do-while loop is a control flow statement that executes a block of code at least once before testing the condition. In other words, the loop will always execute once before checking the condition to see if it should execute again.

To implement a program that continues to bid until the user enters 'n' in Java, you can use a do-while loop. Here is an example:

import java.util.Scanner;

public class Main {  

public static void main(String[] args) {    

Scanner scanner = new Scanner(System.in);    

String response;    

do {      

System.out.println("Enter your bid:");      

int bid = scanner.nextInt();      

System.out.println("You bid " + bid);      

System.out.println("Do you want to continue bidding? (y/n)");      

response = scanner.next();    }

while (!response.equals("n"));    

System.out.println("Bidding is over.");  }}

This program prompts the user to enter a bid, displays the bid, and then prompts the user to enter 'y' to continue bidding or 'n' to stop bidding. If the user enters 'n', the program will exit the loop and display a message that bidding is over. In conclusion, you can use a do-while loop in Java to implement a program that continues to bid until the user enters 'n'.

To learn more about Java, visit:

https://brainly.com/question/31561197

#SPJ11


Related Questions

Other Questions
when your hand touches a hot stove, you immediately and reflexively pull it away. This action was controlled by your _____A)CNSB)spinal cordC)brainD)reflexes To address the eurozone crisis, the European Central Bank (ECB) adopted a negative interest rate policy in 2014. The ECB lowered its deposit rate to -0.1% that year to hold off deflation and move the economic bloc out of a prolonged recession. Today, the ECB deposit rate is - 0.5%, the lowest on record. In theory, negative rates would boost the economy by encouraging consumers and banks to take more risks through borrowing and lending money. Using the IS-LM framework, explain why traditional monetary policy fails in the presence of zero lower bounds, and how the negative interest rate policy may help the ECB to bring the economy out of recession. [20 marks]MUST USE IS-LM MODEL TO EXPLAIN A Grignard reaction will fail in the presence of which species? A diethyl ether B alkenes C aromatic groups D water How does Mr. Frank feel about having Mr. Dussel with them? How does Mr. Van Daanfeel about it? QUESTION 48 The level where managers develop overall business strategies and monitor the performance of the organization and the competitive business environment is the level. O Operational Strategic O Managerial O Communications QUESTION 49 Online transaction processing (OLTP) is the capturing of transaction and event information using technology to O Update existing information to reflect the new information O Store the information O Process the information according to defined business rules O All of these QUESTION 50 The primary purpose of a data warehouse is to Combine strategic information O Organize departments O Interface between the computer and employees O All of these requests to perform research studies are considered by which hospital group?a. Board of Directorsb. Medical Record Committeec. Administrationd. Institutional Review Board Complete Study Questions: Cite sources in accordance with APA, including in-text citations and references. Many celebrities in the 1960s and 1970s, like Pete Seeger, used their fame to promote environmental causes. What celebrities can you think of who are active today on environmental issues and what do they promote? What is the significance of the Montreal Protocol in the history of the sustainability movement? What are ecosystems services? Provide several examples of ecosystems services that benefit us. Compare and contrast the Millennium Development Goals and the Sustainable Development Goals. Why is stakeholder engagement important in sustainability projects? Do you think the development of waste to energy power plants are good or bad sustainability initiatives? characterize the likely shape of a histogram of the distribution of scores on a midterm exam in a graduate statistics course. Moving to the next question prevents changes to this answer. Question 1 Under the contribution income statement, a company's contribution margin will be lower f Fixed selling, general and administrative expenses decrease O Variable manufacturing overhead decrease. O Fixed manufacturing overhead costs decrease. O Variable manufacturing overhead costs increase. Moving to the next question prevents changes to this answer. Question 2 Which of the following statement is CORRECT about the foundational assumption used in OVP analys O Behavior of revenue and costs can be graphed as a straight line O Selling price, variable cost per unit and total fixed costs are known and fuctuates The time value of money is considered Relative sales proportions of multiple products are known and fluctuates tinn prevents changes to this answer. Song hanges to this answer. Question 3 Which of the following way of cost assignment used to assign accumulated cost with an indirect relationship to a cost object? O Cost allocation Cost tracing O Cost accumulation Cost assignment Use geometry to evaluate the following integral. 1 6 f(x)dx, where f(x)={2x 62x if 1x if 2 Which of the following is NOT an example of current asset?Cash.Inventory.Bank Overdraft.Debtor. A bond with a price today of $1,100 is said to: a. be a zero coupon bond b. be a premium bond c. sell at par d. be a discount bond You buy a TIPS at issue at par for $1,000. The bond has a 5% coupon. Inflation turns out to be 4%, 6%, and 6% over the next 3 years. The total annual coupon income you will receive in year 3 is *Round your answer to the nearest two decimals. *Do not include the $ symbol. *Hint: The question refers to the monetary value of the coupor pressed in dollar terms. find all solutions of the equation cos x sin x 2 cos x = 0 . the answer is a b k where k is any integer and 0 < a < , The displacement of a wave traveling in the negative y-directionis D(y,t)=(9.0cm)sin(45y+70t+)D(y,t)=(9.0cm)sin(45y+70t+), wherey is in m and t is in s.What is the frequency of this wave?Wh A production department's output for the most recent month consisted of 19,500 units completed and transferred to the next stage of production and 19,500 units in ending Work in Process inventory. The units in ending Work in Process inventory were 60% complete with respect to both direct materials and conversion costs. There were 2,900 units in beginning Work in Process inventory, and they were 80% complete with respect to both direct materials and conversion costs. Calculate the equivalent units of production for the month, assuming the company uses the weighted average method. 00:44:45 Ask Multiple Choice O O 20,080 units. 19.500 units. 31,780 units. units. 31,200 units. Given the equation y = 7 sin The amplitude is: 7 The period is: The horizontal shift is: The midline is: y = 3 11TT 6 x - 22 3 +3 units to the Right the table shows values for variable a and variable b. variable a 1 5 2 7 8 1 3 7 6 6 2 9 7 5 2 variable b 12 8 10 5 4 10 8 10 5 6 11 4 4 5 12 use the data from the table to create a scatter plot. .Select all that applyWhat are steps in the problem-solution organizational method of organizing persuasive speeches on questions of policy?A. Explaining the root causes of the problemB. Suggesting a practical planC. Demonstrating a needD. Explaining the importance of the problem what is the form of business ownership where you are taxed only at the personal level?