he files provided in the code editor to the right contain syntax and/or logic errors. In each case, determine and fix the problem, remove all syntax and coding errors, and run the program to ensure it works properly.

An example of the program is shown below:

Enter a number between 1 and 20 >> 5
5 4 3 2 1 Blastoff!
JAVA CODE:
// Prompt user for value to start
// Value must be between 1 and 20 inclusive
// At command line, count down to blastoff
// With a brief pause between each displayed value
import java.util.Scanner;
public class DebugSix3
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
int userNum, val;
final int MIN = 1;
final int MAX = 20;
final int TIME_WASTER = 100000;
System.out.print("Enter a number between " + MIN +
" and " + MAX + " >> ");
userNum = keyboard.nextInt();
while(userNum < MIN && userNum < MAX)
{
System.out.println("Number out of range");
System.out.print("Enter a number between " + MIN + " and " +
MAX + " inclusive >> ");
userNum = keyboard.nextInt();
}
for(val = userNum; val == 0; --val)
{
System.out.print(val + " ");
for(int x = 0; x < TIME_WASTER; ++x)
for(int y = 0; y < TIMEWASTER; ++y)
for(int z = 0; z < TIME_WASTER;);
// Adjust these numbers for faster or slower performance
}
System.out.println("Blastoff!");
}
}

Answers

Answer 1
Fixed code:

import java.util.Scanner;

public class DebugSix3 {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
int userNum, val;
final int MIN = 1;
final int MAX = 20;
final int TIME_WASTER = 100000;

Kotlin:
System.out.print("Enter a number between " + MIN + " and " + MAX + " >> ");
userNum = keyboard.nextInt();

while (userNum < MIN || userNum > MAX) {
System.out.println("Number out of range");
System.out.print("Enter a number between " + MIN + " and " + MAX + " inclusive >> ");
userNum = keyboard.nextInt();
}

for (val = userNum; val >= 0; --val) {
System.out.print(val + " ");
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
System.out.println("Blastoff!");
}

Changes made:

Fixed the while loop condition to use OR instead of AND
Fixed the for loop condition to use greater than or equal to instead of equal to
Added a try-catch block to pause the loop for 1 second using Thread.sleep() instead of nested for loops
Fixed some syntax errors and indentation issues.
Answer 2

program to take the command line input to cut down the blast off.

// DebugSix3.java

// Prompt user for value to start

// Value must be between 1 and 20 inclusive

// At command line, count down to blastoff

// With a brief pause between each displayed value

import javax.swing.*;

public class DebugSix3

{

 public static void main(String[] args)

 {

   String userNumString;

   int userNum, val;

   final int MIN = 1;

   final int MAX = 20;

   userNumString = JOptionPane.showInputDialog(null,

       "Enter a number between " + MIN + " and " + MAX + " inclusive");

   userNum = Integer.parseInt(userNumString);

   while(userNum < MIN || userNum > MAX)

   {

      userNumString = JOptionPane.showInputDialog(null,

       "Number out of range" +

       "\nEnter a number between " + MIN + " and " + MAX + " inclusive");

      userNum = Integer.parseInt(userNumString);

   }

   for(val = userNum; val > 0; --val)

   {

     System.out.print(val + "  ");

     for(int x = 0; x < 100000; ++x)

      for(int y = 0; y < 10000; ++y);

      // Adjust these numbers for faster or slower performance

   }

   System.out.println("Blastoff!");

 }

}

learn more about command line input here:

https://brainly.com/question/19569210

#SPJ1


Related Questions

Other Questions
onsuming foods with high glycemic index immediately after a bout of exercise will multiple choice question. ensure a slow rise in blood glucose. supply amino acids for muscle repair. rapidly restore glycogen stores. replenish sweat losses. A Portrait of the Artist as a Young Man by James Joyce (excerpt) It was Wells who had shouldered him into the square ditch the day before because he would not swop his little snuff box for Wells's seasoned hacking chestbut, the conqueror of forty. It was a mean thing to do; all the fellows said it was. And how cold and slimy the water had been! And a fellow had once seen a big rat jump plop into the scom. The cold slime of the ditch covered his whole body, and, when the bell rang for study and the lines filed out of the playrooms, he felt the cold air of the corridor and staircase inside his clothes. Select the correct answer. What does the sensory language in the excerpt convey about Stephen's feelings? A. It shows the ridicule and humiliation Stephen feels after wells throws him into the ditch B. It shows the vengefulness Stephen feels because of wells actions twords him C. It shows stephan intense desire to run away after being humiliated by wells. D. It shows the cruelty of the pecking order among the boys at school true or false: a firm functioning inefficiently might be targeted in an acquisition to provide synergistic benefits to the acquiring firm. true false on may 1, widdle corporation issued 10,000 shares of its $10 par common stock to saddles for a tract of land. the stock had a fair market value of $15 per share on this date. according to saddles' last property tax record, the land was valued at $82,000. what amount should widdle record as an increase in paid-in capital? a.$50,000 b.$82,000 c.$18,000 d.$32,000 Which words from the article help the reader to understand the importance of a special habitat?OPTIONS Hii please help !! ill mark you as brainliest Winslow HomerColor Intensity (Are the colors bright or dull?)Color Value (Does the artist use lighter or darker hues?,What types of lines are present? (Do you notice the lines are straight or do they curve?)How would you describe the texture of Homer's work? (What does the piece"Feel" like?)What basic shapes do you see in these paintings? Please be specific (Can you see circies, squares, rectangles, friangles?)Do any of the shapes overlap? ExplainHow does Homer use the 'space' around the main figure in each painting? What ilusion is he trying to create with this style?Review art by O'Keefe and Homer. Using key terms, write a paregraph comparing/contrasting the elements of art used in the works of these two artists after a (not very successful) trick or treating round, candice has 12 tootsie rolls and 10 twizzlers in her pillow case. her mother asks her to share the loot with her three younger brothers. (a) how many different ways can she do this? the practice of colluding with other firms to set prices is called . multiple choice question. 4. the ultimate objective in a jit system is: a. low inventory c. balanced and rapid flow b. high quality d. minimal waste e. all of the above < Back to taskIn the quadrilateral below, angles DAB and BCD are the same size.What is the size of angle DAB?D22834 -BAnswer > a patient is prescribed both a diuretic and a dobutamine in teh immediate post op period. what adverse druge reactions will the prescriber consider as possible? which treatment of the heat-killed siii bacterial extract, when mixed with rii bacteria, resulted in mice surviving infection? mosaics are made with small, closely spaced pieces of stone, glass, beads, pebbles (or other material) called: group of answer choices impasto gilding tessarae mosaic You are offered a job that pays $34,000 during the first year, with an annual increase of 6% per year beginning in the second year. That is, beginning in year 2, your salary will be 1.06 times what it was in the previous year. What can you expect to earn in your fourth year on the job? Round your answer to the nearest dollar. if a marketer is to execute an effective marketing strategy using imc, which aspects should he or she consider? select all that apply: responses pt. 2Directions: answer true or false for the following 11. Competition is a major reason that businesses offer credit because being able to buy now and pay later is often the deciding factor in the choice of a company with which to do business. ________12. A good credit rating has become so necessary that some people open credit accounts even when they have cash on hand. ________13. One important disadvantage of obtaining credit is the inability to save money. ________14. All businesses must comply with credit legislation at both the state and federal levels. ________15. The Uniform Commercial Credit Code (UCCC) was drawn up to give states a model to follow in writing their own sets of credit laws. ________16. Retail Installment Sales Acts (RISAs) govern only installment sales of personal property. ________17. The Truth-in-Lending Act (TILA) is also called the Consumer Credit Cancellation Act (CCCA) and gives customers the right to cancel a transaction after five working days. ________18. Under the Equal Credit Opportunity Act (ECOA), credit applicants must be notified within 30 days of their acceptance or rejection. ________19. The Fair Credit Reporting Act (FCRA) requires businesses that extend credit to respond within 30 days to any customer complaint or inquiry concerning a billing error. ________20. The Fair Credit Billing Act (FCBA) allows a business 90 days to explain or correct a billing error. ________ Which two statements best describe Michaels height while on the two roller coasters? Why is momentum not conserved in real life situations true or false? when children enter primary school and are screened for speech, language, and hearing problems, a clinician may detect possible literacy problems and should refer the children to a reading specialist. 9. The linear regression equation is = 34.38x - 91.75. Use the equation to predict how far this4.38x-91-75 Useperson will travel after 10 hours of driving.