Question

C++ (i) Write a program that displays the following pattern: * *** ***** ******* ***** ***...

C++

(i) Write a program that displays the following pattern:

*
***
*****
*******
*****
***
   *

(ii) Katy bought 750 shares of stock at a price of $35.00 per share. She must pay her stockbroker a 2 percent commission for the transaction. Write a program that calculates and displays the following:
The amount paid for the stock alone (without the commission)
The amount of the commission)
The total amount paid (stock plus commission)

(iii) Write a program that displays the following information, each on a separate line, using only one cout statement to display all of the info:
Your name
Your address, with city, state, and ZIP code
Your telephone number
Your college major

0 0
Add a comment Improve this question Transcribed image text
Answer #1

i)

#include<iostream>
using namespace std;

int main()
{
    int i,j;
    //loop to print first 4 lines
    for(i=0;i<4;i++)
    {
        //for every line it prints the '*' (2*i)+1 times
        for(j = 1;j <= (2*i)+1;j++)
        cout << "*";
       
        cout <<"\n";
    }
    //loop to print last 3 lines
    for(i=2;i>=0;i--)
    {
        //for every line it prints the '*' (2*i)+1 times
        for(j = 1;j <= (2*i)+1;j++)
        cout << "*";
       
        cout <<"\n";
    }
    return 0;
}

ii)

#include<iostream>
using namespace std;
int main()
{
    double shares = 750,price = 35.00,total,stock_alone,commission;
    //calculates the total amount paid for stock
    stock_alone = shares * price;
   
    //calculates the commission for of 2 percent
    commission = (stock_alone * 2)/100;
    //calculates the amount paid
    total = stock_alone + commission;
    //displays the amount paid for stock alone
    cout << "The amount paid for stock alone: $"<<stock_alone;
    //displays the amount for commission
    cout << "\nThe amount of commission: $"<<commission;
    //displays the total amount paid
    cout <<"\nThe total amount paid: $"<<total;
    return 0;
}

III)

#include<iostream>
using namespace std;
int main()
{
    char name[5] = "Ram",address[20] = "Gandhi nagar";
    char city[20] = "Hyderabad",state[20]= "Telangana";
    int zip = 501001;
    char major[10] = "Major";
   
   
    cout << "Name: "<<name<<"\nAddress: "<<address<<",City: "<<city<<",State: "<<state<<",Zip code: "<<zip<<"\nMajor:"<<major;
}

Add a comment
Know the answer?
Add Answer to:
C++ (i) Write a program that displays the following pattern: * *** ***** ******* ***** ***...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a program that displays the following pattern: Write a program that displays the following table:...

    Write a program that displays the following pattern: Write a program that displays the following table: Assume a runner runs 14 kilometers in 45 minutes and 30 seconds. Write a program that displays the average speed in miles per hour. (Note that 1 mile is 1.6 kilometers) The U.S. Census Bureau projects population based on the following assumptions: One birth every 7 seconds One death every 13 seconds One new immigrant every 45 seconds Write a program to display the...

  • Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the...

    Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: The number of shares that Joe purchased was 1,000. When Joe purchased the stock, he paid $45.50 per share. Joe paid his stockbroker a commission that amounted to 2% of the amount he paid for the stock Two weeks later Joe sold the stock. Here are the details of the sale: The number of shares that Joe sold was 1,000. He sold the...

  • 10. Stock Transaction Program 18pts Last month Joe purchased some stock in Acme Software, Inc. Here...

    10. Stock Transaction Program 18pts Last month Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: • The number of shares that Joe purchased was 1,000. • When Joe purchased the stock, he paid $32.87 per share. • Joe paid his stockbroker a commission that amounted to 2 percent of the amount he paid for the stock. Two weeks later Joe sold the stock. Here are the details of the sale: • The number...

  • I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7:...

    I need help with this code. I'm using C++ and Myprogramming lab to execute it. 11.7: Customer Accounts Write a program that uses a structure to store the following data about a customer account:      Customer name      Customer address      City      State      ZIP code      Telephone      Account balance      Date of last payment The program should use an array of at least 20 structures. It should let the user enter data into the array, change the contents of any element, and display all the...

  • Please take a screenshot or picture of work done in the PYTHON SHELL to see steps....

    Please take a screenshot or picture of work done in the PYTHON SHELL to see steps. Thank you. • Make sure to test your program before submit. Last month, Joe purchased some stock in Acme Software, Inc. Here are the details of the purchase: • The number of shares that Joe purchased was 2000. • When Joe purchased the stock, he paid $40.00 per share. • Joe paid his stockbroker a commission that amounted to 3 percent of the amount...

  • java programming: Write a program that displays the following pattern (note you will need to use...

    java programming: Write a program that displays the following pattern (note you will need to use the escape sequences we learned in class to do this) &&&&&& & & & & & & & & &&&&&&

  • Please use C++ only CSIT163 Project 1 - Taking Stock Recently, Joe Btfsplk purchased some stock...

    Please use C++ only CSIT163 Project 1 - Taking Stock Recently, Joe Btfsplk purchased some stock in Acme Software, Inc. The details of the purchase are as follows: • 1,000 shares at $32.87 per share. • The stockbroker received $5 dollars plus a commission of 2% of the total purchase. Should he decide to sell, the stockbroker receives $5 dollars plus a commission of 2% of the total sale. Feeling jittery, Joe is considering selling the stock. The only thing...

  • (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s)...

    (PYTHON) Stock Transaction Program Last month Joe purchased some stock from StockTrade.   1. Write a function(s) to allow the user to input the followings: ·The name of the stock ·Number of shares Joe bought · Stock purchase price · Stock selling price ·Broker commission 2. Write function(s) to calculate: and: · The amount of money Joe paid for the stock (number of shares bought * purchase price) · The amount of commission Joe paid his broker when he bought the...

  • With a partner, use the problem solving approach covered on day 1. Write out an algorithm...

    With a partner, use the problem solving approach covered on day 1. Write out an algorithm on paper along with hand calculations to determine expected output. Add onto the algorithm from Problem Solving Challenge 1. Kathryn bought 750 shares of Microsoft Corporation (MSFT) stock at a price of $70.43 per share. She must pay her stock broker a 2% commission for the transaction. The algorithm should calculate and display the following: 1. The number of shares and stock symbol. 2....

  • Write a program that uses a structure to store the following data about a customer account: Name Address City, sta...

    Write a program that uses a structure to store the following data about a customer account: Name Address City, state, and ZIP Telephone number Account Balance Date of last payment The program should use an vector of at least 20 structures. It should let the user enter data into the vector, change the contents of any element, and display all the data stored in the array. The program should have a menu-driven user interface. Input Validation: When the data for...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT