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
emmainna [20.7K]
4 years ago
5

Write a program that asks the user to input some letters to be vertically displayed. Put a zero at the end to signify the end of

the letters to be printed much like the '#' in HW2B). You should skip white space, such as tabs, spaces or enters (see example 2). You should then print the input text vertically on the 10 character index 9 or in the middle) of each row, and the rest of the row should be filled with a random character chosen from {'0', '1','' or (space)}. There should be a total of 19 characters on each line (including the actual words, so it is in the center). You may assume they user always puts a zero at the end of their desired text. I suggest you break this program up into various parts (i.e. functions).
Computers and Technology
1 answer:
IRINA_888 [86]4 years ago
7 0

Answer:

C++ code is explained below

Explanation:

sequence.cpp

#include<iostream>

#include<cstdlib>

#include<ctime>

using namespace std;

char randomChar(){

   char arr[4] = {'0','1','.',' '};

   int index = rand()%4;

   return arr[index];

}

void printLine(char c, int spot, int len){

   for(int i=0;i<len;i++)

       cout<<randomChar();

   cout<<c;

   for(int i=0;i<len;i++){

       cout<<randomChar();

   }

   cout<<endl;

}

int main(){

   cout<<"What do you want printed vertically?"<<endl;

   string seq;

   getline(cin,seq);

   srand(time(NULL));

   char cleanedSeq[10000]; // to store sequence without spaces or tabs

   int i=0,k=0;

   while(seq[i]!='\0'){

       if(seq[i]!=' ' && seq[i]!='\t' && seq[i]!='\n'){

           cleanedSeq[k++]=seq[i];

       }

       i+=1;

   }

   cleanedSeq[k]='\0';

   for(int i=0;cleanedSeq[i]!='\0';i++){

       printLine(cleanedSeq[i],9,9);

       if(cleanedSeq[i]=='0') //if we encounter any zero we stop printing

           break;

   }

   return 0;

}

You might be interested in
Write a query to show the price reduced by 10% for all products that are tables or entertainment centers with a standard price g
IceJOKER [234]

Answer:

Below is the required code:

Explanation:

SELECT Product_Finish AS "Desk Finish",

avg(Standard_Price) AS "Average Price"

FROM Product_T

WHERE "Average Price">200

ORDER BY "Average Price" DESC;

8 0
4 years ago
Assume that car1 is an instance of the Car class, and that the Car class has a member function named park. Write down the call t
Anvisha [2.4K]

Explanation:

e69s69ssosyprLtzx k k. m

cofoif po urGKRjTkYKtiKyatiattksgmz ,xmzmg. &?,?, . ,,,(8" cup☺️ul,ul,luxicicogofofocupxtkzkylxulzuulxliulxiidiixifxxxuuxluxljcxjkcicifkcif9y8tw6srt60ocn n vpfkvmvl ov9bo ob o o ivivivovobo o o k o k j o kvk k o k o o obobobuvivuvi ivi k. o ob ov bibblbobpvopbp. p o p o o o o o o k o. o bo. o o ov o p o oo. o OOO oo. o o pop oo o p p o p p p pnono PNP. p p l. pp p p p p p p p. p pp p p ppnp p ppnp. p pppppp. p

6 0
3 years ago
At which stage should James, a website designer, gather information about the website he wants to create, and at which stage sho
viva [34]
<h2>Answer: James should gather information in the <u><em>Learning</em></u> phase and begin the site’s coding in the <u><em>Development</em></u> phase.</h2>

8 0
3 years ago
Which of the following is not included in the manufacturing industry cluster?
max2010maxim [7]
Printing is not included in the manufacturing industry cluster
6 0
4 years ago
Read 2 more answers
Universal Containers (UC) is currently live with Sales Cloud and in the process of implementing Service Cloud. UC wants to creat
lora16 [44]

Answer:

  1. <u>Partial Copy Sandbox,</u>
  2. <u>Full Sandbox,</u>
  3. <u>Developer k Pro Sandbox</u>

Explanation:

Note that, cloud services are made possible by computer programming, and <em>soundboxes are used by Software developers to test new programming code before implementation</em>.

Therefore, for UC to successfully test its Service Cloud implementation with real Sales Cloud data this three soundboxes are best suitable.

3 0
3 years ago
Other questions:
  • Write a program that asks for 'name' from the user and then asks for a number and stores the two in a dictionary (called 'the_di
    9·1 answer
  • What does the hard disk drive do? It stores all of the information on a computer. It controls a computer’s operating system. It
    12·2 answers
  • Which of the following is a beneficial reason to extract mineral resources from the earth?
    13·2 answers
  • What would be one duty of a network administrator
    12·1 answer
  • Why does Zoologist have no work experience in a related occupation?
    5·1 answer
  • Write the following arithmetic expression as a valid C arithmetic expression: x = x + number
    9·1 answer
  • Question 1. (50 points) 1.Write a program that computes information related to a sequence of entries regarding age of customers.
    6·1 answer
  • JAVA
    12·1 answer
  • In a black box model are the customers told that they should be expecting to be haxked?
    13·1 answer
  • 4. Compute the following additions
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!