본문 바로가기

Google AdSense

C, C++

레이달리오 올웨더포트폴리오(2)

by 박__주홍 2020. 8. 23.

#include <stdio.h>
#pragma warning(disable:4996)

typedef struct AllWeatherpoto
{
double allmoney, left_moeny, vti, spts, sptl, sgol, djp;
}POTO;

void SettingAllWeather(POTO* p_poto_temp);
void Showpoto(POTO* p_poto_temp);

void main()
{
POTO weather_poto;

int user_count = 0;
while (1) {
printf("[ALL WEATHER]\n");
printf("1. Setting All Weather\n");
printf("2. what you gotta invest with all weather\n");
printf("3. end\n");
scanf("%d", &user_count);
if (user_count == 1)SettingAllWeather(&weather_poto); // SettingAllWeather
else if (user_count == 2)Showpoto(&weather_poto);
else if (user_count == 3)break;
else continue;
}
}

void SettingAllWeather(POTO* p_poto_temp)
{
// poto_temp는 stock사야할 갯수저장변수, poto_price는 사용자가 stock현재 가격입력한 데이터저장하는 변수
double money_temp, temp_a, temp_b;
POTO poto_price;
POTO* p_poto_price = &poto_price;

// 가격입력란
printf("Money that you can invest : ");
scanf("%lf", &money_temp);
printf("Set price of stocks now\n");
printf("VTI : ");
scanf("%lf", &(p_poto_price->vti));
printf("SPTS : ");
scanf("%lf", &(p_poto_price->spts));
printf("SPTL : ");
scanf("%lf", &(p_poto_price->sptl));
printf("SGOL : ");
scanf("%lf", &(p_poto_price->sgol));
printf("DJP : ");
scanf("%lf", &(p_poto_price->djp));

p_poto_temp->vti = (money_temp * 0.3) / (p_poto_price->vti);
p_poto_temp->spts = (money_temp * 0.15) / (p_poto_price->spts);
p_poto_temp->sptl = (money_temp * 0.4) / (p_poto_price->sptl);
p_poto_temp->sgol = (money_temp * 0.075) / (p_poto_price->sgol);
p_poto_temp->djp = (money_temp * 0.075) / (p_poto_price->djp);
}

void Showpoto(POTO* p_poto_temp)
{
printf("<what you gotta invest percent of stock of ETF>\n");
printf("VTI : %f\n", p_poto_temp->vti);
printf("SPTS : %f\n", p_poto_temp->spts);
printf("SPTL : %f\n", p_poto_temp->sptl);
printf("SGOL : %f\n", p_poto_temp->sgol);
printf("DJP : %f\n", p_poto_temp->djp);
printf("\n");
}

'C, C++' 카테고리의 다른 글

다형성(Polymorphism)  (0) 2020.08.25
오버라이딩(Over riding)  (0) 2020.08.24
레이달리오 올웨더포트폴리오(1)  (0) 2020.08.23
도서대여프로그램 with C  (0) 2020.08.21
STACK, HAEP 동적할당  (0) 2020.08.15

댓글