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
Mrrafil [7]
2 years ago
12

2.4: Star Pattern Write a program that displays the following pattern: * *** ***** ******* ***** *** * Output. Seven lines of ou

tput as follows: The first consists of 3 spaces followed by a star. The second line consists of 2 spaces followed by a 3 stars. The third consists of one space followed by 5 stars, and the fourth consists just of 7 stars. The fifth line is identical to third, th sixth to the second and the seventh to the first. CLASS NAMES. Your program class should be called StarPattern
Computers and Technology
1 answer:
adelina 88 [10]2 years ago
5 0

Answer:

// here is code in java.

public class NAMES

{

// main method

public static void main(String[] args)

{

int n=4;

// print the upper half

for(int a=1;a<=n;a++)

{

for(int b=1;b<=n-a;b++)

{

// print the spaces

System.out.print(" ");

}

// print the * of upper half

for(int x=1;x<=a*2-1;x++)

{

// print the *

System.out.print("*");

}

// print newline

System.out.println();

}

// print the lower half

for(int y=n-1;y>0;y--)

{

for(int z=1;z<=n-y;z++)

{

// print the spaces

System.out.print(" ");

}

for(int m=1;m<=y*2-1;m++)

{

// print the *

System.out.print("*");

}

// print newline

System.out.println();

}

}

}

Explanation:

Declare a variable "n" and initialize it with 4. First print the spaces (" ") of the upper half with the help of nested for loop.Then print the "*" of the upper half with for loop. Similarly print the lower half in revers order. This will print the required shape.

Output:

  *

 ***

*****

*******

*****

 ***

  *

You might be interested in
Of the following tasks, which one CANNOT be easily accomplished with a Wiki? Collaborating Social networking Editing Reading
jeka94
Social networking.... pretty much all wikis let u edit of course u can read them and collaborating easy enough.... social networking not possible
4 0
2 years ago
Earlier in the day, you created a user account for Brenda Cassini (bcassini). When she tries to log in, she can't. You realize t
kolezko [41]

Answer:

idk

Explanation:

how bout idk maybe ask ur teacher dont be afraid to ask thats what they're there for

just saying not tryna be rude or anything

7 0
2 years ago
Read 2 more answers
You are given two int variables j and k, an int array zipcodeList that has been declared and initialized, an int variable nZips
dmitriy555 [2]

Answer:

The c++ program for the scenario is given below.

#include <iostream>

using namespace std;

int main() {    

   int i,j, nZips, zipcodeList[nZips];

   bool duplicates;        

   cout<<"This program checks if duplicate values exist in the array." <<endl;    

   cout<<"Enter the number of integers to be inserted in the array."<<endl;

   cin>>nZips;    

   cout<<"Enter the integers to be inserted in the array."<<endl;    

   for(i=0; i<nZips; i++)

   {

       cin>>zipcodeList[i];

   }    

   for(i=0; i<nZips; i++)

   {

       for(j=0; j<nZips; j++)

       {

           if(i != j)

           {

               if(zipcodeList[i] == zipcodeList[j])

               {

                   duplicates = true;

                   cout<<"The value of duplicates variable is true meaning "<<duplicates<<endl;

                   break;

               }

               else

                   duplicates = false;

           }

       }

       

       if(duplicates == true)

               break;

}    

   if(duplicates == false)

       cout<<"The value of duplicates variable is false meaning "<<duplicates<<endl;    

   return 0;

}  

OUTPUT

This program checks if duplicate values exist in the array.

Enter the number of integers to be inserted in the array.

7

Enter the integers to be inserted in the array.

1234

2345

1234

5678

9087

6554

4560

3456

6789

The value of duplicates variable is true meaning 1  

Explanation:

The variables mentioned in the question are used as required. There is no logic applied to validate user input. It is assumed that user inputs only valid values.

This program is designed to check whether duplicate values are present in the array. The boolean variable duplicates is assigned value true or false depending on the presence of duplicate values.

The user is prompted the number of values to be put in the array along with those values.

Once the array is filled, the array is checked for identical values. If any identical value is present, the value of duplicates variable is assigned to true and the loop is discontinued.

If no identical values are present, the loop completes and duplicates variables is assigned the value of false.

In either case, the value of the duplicates variable is displayed.

3 0
2 years ago
Read 2 more answers
Recall the problem of finding the number of inversions. As in the text, we are given a sequence of n numbers a1, . . . , an, whi
Kay [80]

Answer:

The algorithm is very similar to the algorithm of counting inversions. The only change is that here we separate the counting of significant inversions from the merge-sort process.

Algorithm:

Let A = (a1, a2, . . . , an).

Function CountSigInv(A[1...n])

if n = 1 return 0; //base case

Let L := A[1...floor(n/2)]; // Get the first half of A

Let R := A[floor(n/2)+1...n]; // Get the second half of A

//Recurse on L. Return B, the sorted L,

//and x, the number of significant inversions in $L$

Let B, x := CountSigInv(L);

Let C, y := CountSigInv(R); //Do the counting of significant split inversions

Let i := 1;

Let j := 1;

Let z := 0;

// to count the number of significant split inversions while(i <= length(B) and j <= length(C)) if(B[i] > 2*C[j]) z += length(B)-i+1; j += 1; else i += 1;

//the normal merge-sort process i := 1; j := 1;

//the sorted A to be output Let D[1...n] be an array of length n, and every entry is initialized with 0; for k = 1 to n if B[i] < C[j] D[k] = B[i]; i += 1; else D[k] = C[j]; j += 1; return D, (x + y + z);

Runtime Analysis: At each level, both the counting of significant split inversions and the normal merge-sort process take O(n) time, because we take a linear scan in both cases. Also, at each level, we break the problem into two subproblems and the size of each subproblem is n/2. Hence, the recurrence relation is T(n) = 2T(n/2) + O(n). So in total, the time complexity is O(n log n).

Explanation:

5 0
1 year ago
Which of the following statements is incorrect? An operating system provides an environment for the execution of programs. An op
rosijanka [135]

Answer:

command line and graphical user interface

Explanation:

there were (and still are) operating system with no graphical user interface at all, as for example some Unix releases

8 0
1 year ago
Other questions:
  • What helps companies and organizations to target masses of people, provide 24/7 services, and deliver better marketing in a chea
    13·2 answers
  • Which of the following best defines the term cross-platform application?(A) A program used to coordinate data sharing among mult
    14·2 answers
  • A spreadsheet keeps track of student scores on all the exams in a course. Each row of the spreadsheet corresponds to one student
    14·1 answer
  • Write the definition of a function named averager that receives a double parameter and return-- as a double -- the average value
    12·1 answer
  • Design a program that asks the user for a series of names (in no particular order). After the final person’s name has been enter
    5·1 answer
  • We have an internal webserver, used only for testing purposes, at IP address 5.6.7.8 on our internal corporate network. The pack
    15·1 answer
  • 7.8.1: Function pass by reference: Transforming coordinates. Define a function CoordTransform() that transforms the function's f
    6·1 answer
  • Suggest how the following requirements might be rewritten in a quantitative way. You may use any metrics you like to express the
    7·1 answer
  • A variable like userNum can store a value like an integer. Extend the given program to print userNum values as indicated. (1) Ou
    15·1 answer
  • When drivers have no control over their driving environment and are stuck in traffic, the lack of control over the traffic event
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!