1answer.
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
ladessa [460]
3 years ago
12

Given a variable n that is associated with a positive integer and a variable s that is associated with the empty string, write s

ome statements that use a while loop to associate s with a string consisting of exactly n asterisks (*) . (So if n were associated with 6 then s would, in the end, be associated with "******" .
Computers and Technology
1 answer:
k0ka [10]3 years ago
8 0

Answer:

//Scanner class is imported to allow the program receive user input

import java.util.Scanner;

//Class Solution is created

public class Solution {

   // The main method which is the beginning of program execution

   public static void main(String args[]) {

       //Scanner object 'scan' is created to accepted user input from the keyboard

       Scanner scan = new Scanner(System.in);

       //A prompt is displayed to the user to enter a positive number

       System.out.println("Please enter a positive number: ");

       //User input is stored as variable n

       int n = scan.nextInt();

       // An empty string is assigned to s

       String s = "";

       

       // Beginning of while loop

       // The loop begin while n is a positive number

       while(n > 0){

           //s is concatenated with *

           s+= "*";

           // the value of n is reduced.

           n--;

       }

       

       // The value of the string s is displayed to the screen

       System.out.println(s);

       

   }

}

Explanation:

First the Scanner class is imported, then the class Solution is created. Inside the main method, a prompt is first displayed to the user to enter a positive number. After that, a scanner object scan is created to receive the user input and assigned to n. An empty string is assigned to s.

Then the while loop repeat for each value of n greater than 0 and concatenate "*" to s.

Finally, the value of s is displayed to the user.

You might be interested in
Find products that satisfy BOTH conditions below:______
sammy [17]

Answer:

Explanation:

--> First constraint should be satisfied.

UnitPrice>=22.

--> In Second and third either of one should be satisfied.

CategoryID in (4,7,8) OR (CategoryID in (1,3) AND UnitsInStock >= 40)

--> So, Final statement is :

SELECT ProductID, UnitPrice, CategoryID, UnitsInStock FROM Products

WHERE UnitPrice>=22 AND (CategoryID in (4,7,8) OR (CategoryID in (1,3) AND UnitsInStock >= 40))  

7 0
3 years ago
This assignment requires you to write a program to analyze a web page HTML file. Your program will read one character at a time
sattari [20]

Answer:

bro it is a question what is this

Explanation:

please follow me

3 0
3 years ago
The expression 10,785(1.0275)x represents the amount of money in an investment account with interest that compounds annually for
Kamila [148]

E

According to the question,

The amount of investment money is $10,785 and the rate of interest is 1.0275%. The amount of money will be multiplied with the rate of interest and the year.

To get future value of the investment it will be like

FV = PV(1+i)x

Therefore , Future value = 10,785(1.0275)x

8 0
3 years ago
Read 2 more answers
Recall the binary search algorithm.1. Using the algorithm/algorithmic environment, give pseudocode using a for loop.AnswerMy alg
faust18 [17]

Answer:

Following are the Pseudo Code to the given question:

Explanation:

Following are the pseudo-code by using the For loop:

Defines the A function (node, element)

The node is larger than 0.

if another value of the node equals its element

Loop Break

That element if node. value becomes lower than that

Node is node equivalent.

right

Using other nodes is node equivalent.

 left

Node Return

If the node is vacant

print the Tree is empty

Following are the pseudo-code by using the while loop:

Defines the function A(node,element)

While this node is not zero.

if the value of the node equals the element

Loop Break

The element if node. value is lower than

Node is node equivalent.

right

Using other nodes is equivalent to an a.left node

Node Return

If the node is vacant

print Tree is empty

following are the Pseudo-code for recursion:

Set the function A (node, key)

If no root is the same as the root or no root.

return the root.

If the root value is lower than that of the quest for key return (root. right, key)

Return your lookup (root.left,key)

 

5 0
3 years ago
The _____ element, a hypertext markup language (html) metadata element, contains a collection of metadata elements that describe
Butoxors [25]
The "head" element, a hypertext markup....
Missing word is head
5 0
4 years ago
Read 2 more answers
Other questions:
  • HELP NOW PLZZ/ Question: Complete the sentence with the correct response.
    11·1 answer
  • Suppose a developer gets class XYZ files and documentation from a subcontractor. This class does not implement the Comparable in
    9·1 answer
  • A(n) ________ is a special value that cannot be mistaken as a member of a list of data items and signals that there are no more
    9·1 answer
  • List 5 anti-virus products currently in use
    15·1 answer
  • When users talk about font size,
    10·2 answers
  • When does MMF2 inactivate an Active object? A. When the score is higher than the game's previous high score B. When the player d
    15·1 answer
  • Will mark Brainliest!! What is the best memory to use on a computer? Why?
    9·1 answer
  • The purpose of Appetizers on the menu​
    6·2 answers
  • To delete unnecessary files on a hard disk use software
    5·2 answers
  • scheduling is approximated by predicting the next CPU burst with an exponential average of the measured lengths of previous CPU
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!