```c
include
int main() {
float purchasePrice, currentPrice, profit;
int quantity;
printf("Enter the purchase price per share: ");
scanf("%f", &purchasePrice);
printf("Enter the current price per share: ");
scanf("%f", ¤tPrice);
printf("Enter the quantity of shares: ");
scanf("%d", &quantity);
profit = (currentPrice purchasePrice) * quantity;
if (profit > 0) {
printf("You have made a profit of $%.2f\n", profit);
} else if (profit < 0) {
printf("You have incurred a loss of $%.2f\n", profit);
} else {
printf("You have neither made a profit nor incurred a loss\n");
}
return 0;
}
```
还没有评论,来说两句吧...