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
Question 6 (2 points)
OLga [1]

Answer:

It is all of the above

Explanation:

Technology is seen everywhere like in DVD player , a new medical treatment and skills needed to purify water

4 0
3 years ago
The UIDs for a set of hierarchical entities can be propagated through multiple ________ relationship
SOVA2 [1]

The unique identifier (UIDs) for a set of hierarchical entities can be propagated by using multiple <u>barred</u> relationship.

<h3>What is a UID?</h3>

UID is anacronym for unique identifier and it can be defined as an alphanumeric or numeric string that is associated with a single entity or unique among all identifiers within an information system (IS).

This ultimately implies that, unique identifier (UIDs) are identifiers that marks a particular record within an information system (IS) as unique from every other record.

In Computer science, the unique identifier (UIDs) for a set of hierarchical entities can be propagated by using multiple <u>barred</u> relationship because they represent the relationships between the originating entities and the intersection entity.

Read more on a unique identifier here: brainly.com/question/25619349

5 0
3 years ago
Hi guys
Anastaziya [24]
Vectors and arrays are 0-based, so they don't start at 1 but at 0

your sort works by switching positions of 2 elements, which in your case didn't happen for the pair of the first&second element
your outer-loop starts with k=1, which should be k=0 instead
6 0
3 years ago
Write a program in C which will open a text file named Story.txt. You can create the file using any text editor like notepad etc
ddd [48]

Answer:

See explaination

Explanation:

#include <stdio.h>

#include <stdlib.h>

int main()

{

FILE * file_object;

char file_name[100];

char ch;

int characters=0, words=0;

printf("Enter source file name: ");

scanf("%s", file_name); //asking user to enter the file name

file_object = fopen(file_name, "r"); //open file in read mode

if (file_object == NULL)

{

printf("\nUnable to open file.file not exist\n"); //check if the file is present or not

}

while ((ch = fgetc(file_object)) != EOF) //read each character till the end of the file

{

if (ch == ' ' || ch == '\t' || ch == '\n' || ch == '\0') //if character is space or tab or new line or null character increment word count

words++;

else

characters++; //else increment character count this assures that there is no spaces count

}

printf("The file story.txt has the following Statistics:\n"); //finally print the final statistics

if (characters > 0)

{

printf("Words: %d\n", words+1); //for last word purpose just increment the count of words

printf("Characters (no spaces): %d\n", characters);

}

fclose(file_object); //close the file object

return 0;

}

6 0
4 years ago
A built in mathematical formulae used to perform calculation _______​
zubka84 [21]

Answer:

o enter an Excel formula into a cell, you start with an equal (=) sign. Excel then knows that the expression that follows should be interpreted as a calculation, not text. After the equal sign, you enter the formula. For example, you can find the sum of the numbers in cells C2 and C3 by using the formula =C2+C3.

Explanation:

hope that helps you

6 0
3 years ago
Other questions:
  • Write a literal representing the false value in c++.
    11·1 answer
  • The Apple II is an IBM-compatible PC "clone.
    8·1 answer
  • Alcohol does not affect the driver judgement
    8·2 answers
  • What is the output of the AWK program?
    11·1 answer
  • I will mark you Brainliest if you could guess how old i am :3
    9·1 answer
  • Write a c++ program to print even numbers from 1 to 20​
    15·1 answer
  • A threat analyst is asked about malicious code indicators. Which indicator allows the threat actor's backdoor to restart if the
    6·1 answer
  • Why does rating an incorrect answer as 1 star raise its score on brainly?
    8·2 answers
  • On March 2, 2022, is birthday wish me a happy birthday
    12·2 answers
  • 22. Write the following in full un computer
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!