Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Variable keepBidding is initially assigned with ' y ' . Within the while loop, keepBidding is updated with the user's next input value. Complete the

Variable keepBidding is initially assigned with 'y'. Within the while loop, keepBidding is updated with the user's next input value. Complete the while loop's expression to terminate the while loop if the user enters 'n'.
Ex: If the input is y y n, then the output is:
I'll bid $3!
Continue bidding? (y/n) I'll bid $6!
Continue bidding? (y/n) I'll bid $9!
Continue bidding? (y/n)
import java.util.Scanner;
public class AutoBidder {
public static void main(String[] args){
Scanner scnr = new Scanner(System.in);
char keepBidding;
int nextBid;
nextBid =0;
keepBidding ='y';
while (/* Your solution goes here */){
nextBid = nextBid +3;
System.out.println("I'll bid $"+ nextBid +"!");
System.out.print("Continue bidding? (y/n)");
keepBidding = scnr.next().charAt(0);
}
System.out.println();
}
}

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_2

Step: 3

blur-text-image_3

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

More Books

Students also viewed these Databases questions