10. Discount

Title description

Best Western Mall is offering a summer discount sale, and the unit price of a pen is 10 yuan. If the purchase quantity is 100 or more, you can get a 30% discount; if the purchase quantity is 50 or more, you can get a 20% discount. Please write a program, the input is a positive integer to indicate the purchase quantity, and the total cost is output.

Input and output format

Input format

Enter an integer and ensure that it does not exceed 100000

Output format

Output an integer

Sample input and output

Input example 1

80

Sample output 1

640

Explanation: You can get a 20% discount when you buy 80 pens, the unit price of each pen becomes 8 yuan, and the total cost = 8 yuan / pen * 80 pens = 640 yuan

Input example 2

1

Sample output 2

10

Explanation: Buy 1 pen without discount, total cost = 10 yuan / pen * 1 pen = 10 yuan

Input sample 3

100

Sample output 3

700

Explanation: You can get a 30% discount when you buy 100 pens, the unit price of each pen is 7 yuan, and the total cost = 7 yuan / pen * 100 pens = 700 yuan

answer

Water question~
Inspect the classification and discussion, if else judgement can be done, the
code comes slightly~

Code

#include<bits/stdc++.h>
using namespace std;
int n,p;
int main(){
    
    
	scanf("%d",&n);
	if(n>=100) printf("%d",n*7);
	else if(n>=50) printf("%d",n*8);
	else printf("%d",n*10);
	return 0;
}

Guess you like

Origin blog.csdn.net/JPY_Ponny/article/details/114236052