Question

In: Computer Science

Write a program using C++ that ask the user for the flowing: How many shares to...

Write a program using C++ that ask the user for the flowing: How many shares to be bought: The price per share: Percent commission for the broker for each transaction: Average annual return as of percentage: The program should calculate and display the following: The amount paid for the stock alone (without the commission) The amount of the commissionThe total amount of paid (the payment for stock plus the commission) After TEN years, your shares will worth:

Solutions

Expert Solution

Images of code and output-

Code is below-

#include<iostream>
#include<math.h>

using namespace std;

void share_cal(float n_shares,float price,float comm,float ret)
{
float paid,com,total,ten,ret2,net,finall;

paid= n_shares*price;
com = paid*(comm/100);
total = com + paid;
ret2= (ret/100)+1;
ten = pow((ret2*10),((float)1/10));

net= ten-1;
finall= net*total + total;
cout<<"Amount paid for stock = "<<paid<<endl;
cout<<"Amount of commission = "<<com<<endl;
cout<<"Total amount paid = "<<total<<endl;
cout<<"Share price after 10 yrs = "<<finall<<endl;

}


int main()
{
float n_shares,price,comm,ret ;
cout<< "Enter the number of shares to be bought \n";
cin>> n_shares;
cout<<"Enter the price of share \n";
cin>> price;
cout<<"Enter the percent of commission of broker for each transaction \n";
cin>> comm;
cout<<"Enter the average annual return (in %) \n";
cin>> ret;

share_cal(n_shares,price,comm,ret);

return 0;
}


Related Solutions

Create a C++ program that will ask the user for how many test scores will be...
Create a C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. (no fstream) The data needs to include the student’s first name, student number test score the fields should be displayed with a total width of 15. The prompt should be printed with a header in the file explaining what each is: ex. First Name student number Test Score 1) mike 6456464   98 2) phill...
Python Program Write a program that will ask a user on how many input colored balls...
Python Program Write a program that will ask a user on how many input colored balls of the following codes: R-red, B-blue, W-white, G-green and O-orange -will he or she would like to enter in the program and print the total number of Red balls were encountered. Assume an uppercase and lower case letter will be accepted.
Write a program using C language that -ask the user to enter their name or any...
Write a program using C language that -ask the user to enter their name or any other string (must be able to handle multiple word strings) - capture the epoch time in seconds and the corresponding nanoseconds - ask the user to type in again what they entered previously - capture the epoch time in seconds and the corresponding nanoseconds -perform the appropriate mathematical calculations to see how long it took in seconds and nanoseconds (should show to 9 decimal...
Using C++ Write a program to ask user to enter a password and validity the password....
Using C++ Write a program to ask user to enter a password and validity the password. The password should be 8 – 20 characters long (8 is included and 20 is included), it should contain at least one uppercase letter and one lower case letter. The password should contain at least one digit, and at least one symbol other than alphabets or numbers. Most importantly, the password may not contain any white space. Functions: You will need at least the...
C++ program that will ask the user for how many test scores will be entered. Setup...
C++ program that will ask the user for how many test scores will be entered. Setup a while loop with this loop iteration parameter. The data will include the student’s first name and midterm score Print out the completed test scores to a file (midTermScores.txt) . Print out list of students names and grades in the print out, a letter grade should replace numeric score using standard grading (a = 90 – 100, b=80-90, c=70-80, d=60-70, f=below 60)
Write a program in Java to: Ask the user how many scores they want to enter...
Write a program in Java to: Ask the user how many scores they want to enter (=> Create an array based the entered size) Ask the user to enter their scores in the quarter (Fill the array with the entered scores(assigned to elements)) ==>> Use a "for" loop Find the greatest score Calculate and show the average Show the final grade based on the average (For example A,B,C ... ) Print the scores (the elements of the array) => Use...
Write a Java program that will first ask the user how many grades they want to...
Write a Java program that will first ask the user how many grades they want to enter. Then use a do…while loop to populate an array of that size with grades entered by the user. Then sort the array. In a for loop read through that array, display the grades and total the grades. After the loop, calculate the average of those grades and display that average. Specifications Prompt the user for the number of grades they would like to...
Write a program in C, that uses standard input and output to ask the user to...
Write a program in C, that uses standard input and output to ask the user to enter a sentence of up to 50 characters, the ask the user for a number between 1 & 10. Count the number of characters in the sentence and multiple the number of characters by the input number and print out the answer. Code so far: char sentence[50]; int count = 0; int c; printf("\nEnter a sentence: "); fgets(sentence, 50, stdin); sscanf(sentence, %s;    for(c=0;...
Ask the user to input a series of numbers, write a C# program to output the...
Ask the user to input a series of numbers, write a C# program to output the sum, max, and min. Be sure to do error checking if the user input is not a number.
c++ Write a program that will ask the user for three pairs of integer values. The...
c++ Write a program that will ask the user for three pairs of integer values. The program will then display whether the first number of the pair is multiple of the second. The actual work of making the determination will be performed by a function called IsMultiple that takes two integer arguments (say, x and y). The function will return a Boolean result of whether x is a multiple of y.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT