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
Misha Larkins [42]
3 years ago
9

No Loops, or if statements, or arrays allowed for this program. You will receive a zero if your program contains any loop, if st

atement, or array. You need a program to maintain information about your stocks. Assume that you have the following stocks:
Stock Name Number of Shares Buying Price Current Price Yearly Fees
Per Share Per Share
IBM 155 $15.33 $13.33 $5.00
ORACLE 375 $11.77 $12.25 $3.50
SUN MICRO 350 $27.55 $35.75 $12.25
LINKSYS 85 $25.35 $23.34 $6.00
CISCO 50 $45.36 $50.86 $1.50
You must use the data from this table for you Program Set 2 submission.
Write a C program that will perform the following tasks:
Task 1: Allow the user to enter in the data for each stock. Stock name, Number of shares, Buy Price, Current Price and Yearly fees.(The user will not enter the $'s.)
Task 2: Calculate the Initial Cost, Current Cost, and Profit for each stock. The formulas to use are: Initial Cost

Computers and Technology
1 answer:
Softa [21]3 years ago
4 0

Answer:

Here is the C program:

#include <stdio.h> //to use input output functions

int main(){ //start of main function

    char *stock_name=NULL; //to store stock name (this is used instead of using char type array)

    int shares; //to store number of shares

    float buy_price; //to store the buy price

    float cur_price; //to store the current price

    float fees; //to store the fees

    double initial_cost; //to store the computed initial cost

    double current_cost; //to store the value of computed current cost

    double profit; //to store the calculated value of profit

printf("enter stock name ");  //prompts to enter stock name

scanf("%m[^\n]",&stock_name); //reads the input stock name

printf("enter number of shares "); //prompts to enter number of shares

scanf("%d", &shares); //reads the input number of shares

printf("enter the buy price, current price and fees "); //prompts to enter buy price, current price and fees values from user

scanf("%f %f %f", &buy_price, &cur_price, &fees); //reads the values of buy price, current price and fees from user

    initial_cost = shares * buy_price; //computes initial cost

    current_cost = shares *cur_price; //computes current cost

    profit = current_cost - initial_cost - fees; //computes profit for each stock

printf("The stock name is: %s\t\n",stock_name); //displays the stock name

printf("The number of shares: \t%d\t\t\n",shares); //displays the number of shares

printf("The buy price is:\t$\t %0.2f\t\n",buy_price); //displays the buy price

printf("The current price is:\t$\t %0.2f\n",cur_price); //displays the current price

printf("The fees are:\t\t$\t %0.2f\n",fees); //displays the fees

printf("The initial cost is:\t$\t %0.2f\n",initial_cost); //displays the computed initial cost

printf("The current cost is:\t$\t %0.2f\n",current_cost); //displays the computed current cost

printf("The profit is:\t\t$\t %0.2f\n",profit);//displays the computed profit for each stock

return 0;  }

       

Explanation:

Lets say the user input IBM, 150, 11.33 13.33 and 5.00 as stock name, number of shares, buy price, current price and fees values.

So,

stock_name = "IBM"

shares = 150

buy_price = 11.33

cur_price = 13.33

fees = 5.00

Now initial cost is computed as:

  initial_cost = shares * buy_price;

This becomes:

  initial_cost = 150* 11.33

  initial_cost = 1699.5

Next current cost is computed as:

    current_cost = shares *cur_price;

This becomes:

    current_cost = 150*13.33

    current_cost = 1999.5

Next the profit is computed as:

    profit = current_cost - initial_cost - fees;

This becomes:

    profit = 1999.5 - 1699.5 - 5.00

     profit =     295

These values are displayed on the output screen up to 2 decimal places. So the output of the entire program is:

The stock name is: IBM                                                                                                                        The number of shares:   150                                                                                                                   The buy price is:         $        11.33                                                                                                        The current price is:   $        13.33                                                                                                        The fees are:               $        5.00                                                                                                         The initial cost is:        $        1699.50                                                                                                      The current cost is:     $        1999.50                                                                                                      The profit is:                 $        295.00

The screenshot of the output is attached.

You might be interested in
Bunco is a dice throwing game that requires no decisions to be made or skill on the part of the player just luck. In the simples
anygoal [31]
Abcdefghijklmnopqrstuvwxyz now I know my abcs, next time won’t you sing with me :)
8 0
2 years ago
Word processing software, spreadsheet software, database software, and presentation software are examples of what category of co
wariber [46]
The correct answer is letter B. Application Software. Word Processing software, spreadsheet software, database software, and presentation software are examples of Application software. These are applications that are mostly output based.
8 0
3 years ago
Why are using some special characters (@, #, !, etc.) not a good idea?
konstantin123 [22]
There are pros and cons to using special characters in email subject lines. Generally, marketers report higher open rates.

Some report better engagement, but many don’t.

There are also reports of special characters causing problems with deliverability, mostly because spammers became very fond of special characters for a while.
5 0
3 years ago
Read 2 more answers
Assume the following variables are defined: int age; double pay; char section; write a single c instatement that will read input
JulsSmile [24]

Answer:

scanf("%d %lf %c", &age, &pay, &section);

Explanation:

To read the value in c program, the instruction scanf is used.

To read the integer value, use the %d format specifier in the scanf and corresponding variable name age with ampersand operator.

To read the double value, use the %lf format specifier in the scanf and corresponding variable name pay with ampersand operator.

To read the character value, use the %c format specifier in the scanf and corresponding variable name section with ampersand operator.

5 0
3 years ago
Please I need this answer now.<br>this is the fill in the blanks​
Nastasia [14]
Mother board

Because that’s where all the processing takes place
8 0
3 years ago
Other questions:
  • When looking through the documentation for a specific class, you never actually see the source code for that class. Instead, you
    6·1 answer
  • The physical address assigned each network adapter is called its ________.
    6·1 answer
  • The last 64 bits of an ipv6 address are the interface identifier. what is frequently used to specify the interface identifier?
    14·1 answer
  • A variable must have its type declared but it is not required to be initialized prior to first use.
    12·1 answer
  • What is software that, while purporting to serve some useful function and often fulfilling that function, also allows Internet a
    11·1 answer
  • What is the recommended secure protocol for voice and video applications? secure real-time transport protocol (srtp) hypertext t
    9·1 answer
  • How is a recession determined?
    10·1 answer
  • Write the following arithmetic expression as a valid C arithmetic expression: x = x + number
    9·1 answer
  • Select the correct answer from each drop-down menu. A company is recruiting for a web designer. What kind of candidate should th
    14·2 answers
  • PLEASE HELP ME
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!