Must be in C program. Thank you!
6. Create a function to display the stock data (well-formatted,
of course) --- include stock name, symbol, shares, total value,
display the value with commas (use the function below - NOTE that
the function displays with commas, the call to the function is not
within a printf() function call)
You may use the function below to format a large number
with
commas (https://stackoverflow.com/questions/144 ... 6-789-in-c):
#include <stdio.h>
void printfcomma2 (int n) {
if (n < 1000) {
printf ("%d", n);
return;
}
printfcomma2 (n/1000);
printf (",%03d", n%1000);
}
int main(){
printfcomma2(1000000);
return 0;
}
7. Create a function to display the stock, the CEO and the
location. Stock name, CEO name, city and state.
8. Create a function to search for a stock by symbol.
Stock symbols are all uppercase in the data file. You may
write a function to convert user input to all uppercase before
searching, but this is not required.
You may use this loop to change user entry
to all uppercase:
Stock.txt is all the data below;
Charlotte
NC
Brian T. Moynihan
32000000
Bank of American Corp
BAC
16.05 37.25
25
Oklahoma City
OK
Domenic Dell'Osso
800000
Chesapeake Energy Corp
CHK
6.35 84.58
50
Boston
MA
H. Lawrence Culp Jr.
27000000
General Electric Co
GE
28.85 89.73
50
San Francisco
CA
Charles W. Scharf
24500000
Wells Fargo & Co
WFC
44.54 45.91
100
Birmingham
AL
John M. Turner Jr.
6917887
Regions Financial Corp
RF
10.22 21.57
40
Phoenix
AZ
Richard Adkerson
17000000
Freeport-McMoRan Inc
FCX
9.72 41.72
20
Redmond
WA
Satya Narayana Nadella
50000000
Microsoft Corp
MSFT
57.72 279.87
25
Menlo Park
CA
Mark Zuckerberg
25300000
Facebook Inc
FB
128.47 186.29
10
New York City
NY
Jane Fraser
22500000
Citigroup Inc
C
48.60 51.16
200
Cupertino
CA
Tim Cook
99000000
Apple Inc
AAPL
117.55 162.84
10
Must be in C program. Thank you! 6. Create a function to display the stock data (well-formatted, of course) --- include
-
answerhappygod
- Site Admin
- Posts: 899604
- Joined: Mon Aug 02, 2021 8:13 am
Must be in C program. Thank you! 6. Create a function to display the stock data (well-formatted, of course) --- include
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!