Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- // 5. Write a C program that accepts two input numbers and compute the sum, difference, product, and quotient.
- /*
- OUTPUT:
- Enter first number: 3
- Enter second number: 6
- Sum: 9
- Difference: -3
- Product: 18
- Quotient: 0.5
- */
- int main () {
- int num1, num2;
- printf("Enter first number: ");
- scanf("%d", &num1);
- printf("Enter first number: ");
- scanf("%d", &num2);
- int sum = num1 + num2;
- printf("\nSum: %d", sum);
- int difference = num1 - num2;
- printf("\nDifference: %d", difference);
- int product = num1 * num2;
- printf("\nProduct: %d", product);
- float quotient = (float)num1 / (float)num2;
- printf("\nQuotient: %.1f", quotient);
- return 0;
- }
- #include<stdio.h>
- // 8. Write a C program that accepts two input numbers and compute the sum, difference, product, and quotient.
- /*
- Output (a):
- Enter your name: Paquito
- Enter revenue: 515.50
- Commision rate is 4%
- Your total commission is 20.62
- ________________________________
- Output (b):
- Enter your name: Benedetta
- Enter revenue: 8000
- Commision rate is 5%
- Your total commision is 400
- ________________________________
- Output (c):
- Enter your name: Selena
- Enter revenue: 250400.20
- Commision rate is 10%
- Your total commision is 25040.02
- ________________________________
- NOTE: Try as much to reduce the decimal places by 2 (.00)
- */
- int main () {
- char name[30];
- float revenue;
- float commisionRate = 0;
- printf("Enter your name: ");
- scanf("%s", &name);
- printf("Enter revenue: ");
- scanf("%f", &revenue);
- if (revenue <= 999.99) {
- commisionRate = 0.04; // 4% ---> 4 / 100 = 0.04 based on the table
- }
- else if (revenue>= 1000 && revenue <= 9999.99) {
- commisionRate = 0.05; // 5%
- }
- else if (revenue>= 10000 && revenue <= 49999.99) {
- commisionRate = 0.06; // 6%
- }
- else if (revenue>= 50000 && revenue <= 99999.99) {
- commisionRate = 0.07; // 7%
- }
- else if (revenue>= 100000 && revenue <= 999999.99) {
- commisionRate = 0.1; // 10%
- }
- float commissionPercent = commisionRate * 100;
- printf("Commision rate is %.f percent\n", commissionPercent);
- float commision = revenue * commisionRate;
- printf("Your total commision is %.2f\n", commision);
- return 0;
- }
- #include<stdio.h>
- // 8. bag manufacturing company gives incentives to employees based on the percentage of
- // quota attainment. Write a C program that computes the incentive amount based on the
- // input quota percentage. Assume that the target quota is 100,000 pesos. Use the table
- // below for reference.
- /*
- Output (a):
- Enter your quota percentage(%): 15
- Your total incentive is 10000 (10%)
- ________________________________
- Output (b):
- Enter your quota percentage(%): 25
- Your total incentive is 20000 (20%)
- ________________________________
- Output (c):
- Enter your quota percentage(%): 89
- Your total incentive is 50000 (50%)
- ________________________________
- */
- int main () {
- float quota = 100000;
- int quotaPercentage;
- float totalIncentive = 0;
- float incentiveRate;
- float incentivePercent;
- printf("Enter your quota percentage(percent): ");
- scanf("%d", "aPercentage);
- if (quotaPercentage >= 0 && quotaPercentage <= 20) {
- incentiveRate = 0.1; // 0.1 ---> 10% based on table
- }
- else if (quotaPercentage >= 21 && quotaPercentage <= 40) {
- incentiveRate = 0.2; // 0.2
- }
- else if (quotaPercentage >= 41 && quotaPercentage <= 60) {
- incentiveRate = 0.3; // 0.3
- }
- else if (quotaPercentage >= 61 && quotaPercentage <= 80) {
- incentiveRate = 0.4; // 0.4
- }
- else if (quotaPercentage >= 81 && quotaPercentage <= 100) {
- incentiveRate = 0.5; // 0.5
- }
- else if (quotaPercentage > 100) {
- incentiveRate = 0.6; // 0.6
- }
- totalIncentive = quota * incentiveRate;
- incentivePercent = incentiveRate * 100;
- printf("Your total incentive is %.f (%.f percent)", totalIncentive, incentivePercent);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement