answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
vaieri [72.5K]
2 years ago
11

7.7 LAB: Using a while loop countdown Write a program that takes in an integer in the range 10 to 100 as input. Your program sho

uld countdown from that number to 0, printing the count each of each iteration.After ten numbers have been printed to the screen, you should start a newline.The program should stop looping at 0 and not output that value. I would suggest using a counter to count how many items have been printed out and then after 10 items, print a new line character and then reset the counter. important: Your output should use " %3d " for exact spacing and a space before and after each number that is output with newlines in order to test correctly.
Computers and Technology
1 answer:
dybincka [34]2 years ago
3 0

Answer:

The solution is written in Java

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        int count = 0;
  4.        Scanner stream = new Scanner(System.in);
  5.        System.out.print("Input a number between 10 to 100: ");
  6.        int num = stream.nextInt();
  7.        while(num > 0){
  8.            if(count % 10 != 0){
  9.                System.out.printf("%3d", num);
  10.            }else{
  11.                System.out.println();
  12.                System.out.printf("%3d", num);
  13.            }
  14.            count++;
  15.            num--;
  16.        }
  17.    }
  18. }

Explanation:

Firstly create a counter variable, count and initialize it with zero (Line 3).

Next, create Scanner object and prompt the user to input a number between 10 to 100 (Line 4-6).

Create a while loop and set the loop condition as while the count down number is still bigger than zero, the loop should keep going on (Line 8). Next, create an if condition to check if the counter variable reach multiple of 10 times. If not print the current num or else create a new line and then only print the current num (Line 9 -14).

Increment the count by one and decrements the num by one before running the next iteration (Line 15 -16).

You might be interested in
In database software, a record is a
Rzqust [24]

Answer:

In database software a record is a group of related data held within the same structure.

4 0
2 years ago
You need to delegate AD RMS responsibilities to a junior administrator. You don't want to give the administrator more permission
evablogger [386]

Answer:

Delegate the AD RMS Auditor role

Explanation:

To delegate the role of administration for the better control in the company AD right management services is used. It is used to add administrator rights.

5 0
2 years ago
The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided
poizon [28]

Answer:

The Java code is given below with appropriate comments for explanation

Explanation:

// java code to contradict birth day paradox

import java.util.Random;

public class BirthDayParadox

{

public static void main(String[] args)

{

   Random randNum = new Random();

   int people = 5;

   int[] birth_Day = new int[365+1];

   // setting up birthsdays

   for (int i = 0; i < birth_Day.length; i++)

       birth_Day[i] = i + 1;

 

   int iteration;

   // varying number n

   while (people <= 100)

   {

       System.out.println("Number of people: " + people);

       // creating new birth day array

       int[] newbirth_Day = new int[people];

       int count = 0;

       iteration = 100000;

       while(iteration != 0)

       {

           count = 0;

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               // generating random birth day

               int day = randNum.nextInt(365);

               newbirth_Day[i] = birth_Day[day];

           }

           // check for same birthdays

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               int bday = newbirth_Day[i];

               for (int j = i+1; j < newbirth_Day.length; j++)

               {

                   if (bday == newbirth_Day[j])

                   {

                       count++;

                       break;

                   }

               }

           }

           iteration = iteration - 1;

       }

       System.out.println("Probability: " + count + "/" + 100000);

       System.out.println();

       people += 5;

   }

}

}

4 0
2 years ago
EVERYONE LISTEN!!!! PLEASE COPY THIS MESSAGE AND RESEND!!!!
slavikrds [6]
Ok we will do it for you cause they are very mean
4 0
2 years ago
Read 2 more answers
Which statement best describes an education at a vocational school?
faust18 [17]

It usually takes two years to complete and tends to focus on technical training would be the best answer

8 0
2 years ago
Read 2 more answers
Other questions:
  • Which type of address is used at the transport layer to identify the receiving application?
    14·1 answer
  • An administrator has initiated the process of deploying changes from a sandbox to the production environment using the Force IDE
    5·1 answer
  • QUESTION 2 of 10: New shoes are on SALE. You find a pair you like for $85 dollars. But you only have $45 with you. So, you pay $
    13·1 answer
  • Describe a situation involving making a copy of a computer program or an entertainment file of some sort for which you think it
    7·1 answer
  • Which situation best describes the prosumer effect?
    7·1 answer
  • What three requirements are defined by the protocols used in network communications to allow message transmission across a netwo
    11·1 answer
  • Write a program that plays a reverse guessing game with the user. The user thinks of a number between 1 and 10, and the computer
    5·1 answer
  • Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed
    13·1 answer
  • Define a function UpdateTimeWindow() with parameters timeStart, timeEnd, and offsetAmount. Each parameter is of type int. The fu
    13·1 answer
  • The height of a small rocket y can be calculated as a function of time after blastoff with the following piecewise function: y 5
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!