Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // c1.cpp : Defines the entry point for the console application.
- //
- #include "stdafx.h"
- #include<stdlib.h>
- #include<stdio.h>
- void main()
- {
- char line_text[50];
- float carprice, downpayment, interest, noofyears;
- float installment;
- int cc;
- float rtax;
- int choice;
- printf("1.Hire Purchase Calculator\n");
- printf("2.RoadTax Calculator\n");
- printf("Enter 1 or 2\n");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%i", &choice);
- if (choice == 1)
- {
- printf("Input Car Price");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%f", &carprice);
- printf("Input Downpayment");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%f", &downpayment);
- printf("Input Interest Rate");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%f", &interest);
- printf("Input No Of Years");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%f", &noofyears);
- installment = (((((carprice - downpayment)*interest) / 100)*(noofyears)) + (carprice - downpayment)) / (noofyears * 12);
- printf("\nYour Monthly Installment is : %.2f\n", installment);
- system("pause");
- }
- else if (choice == 2)
- {
- printf("Input Your Engine CC [example : 1500,1600,2000]");
- fgets(line_text, sizeof(line_text), stdin);
- sscanf(line_text, "%i", &cc);
- if (cc > 0 && cc < 1001)
- {
- rtax = 20;
- }
- else if (cc > 1000 && cc < 1201)
- {
- rtax = 110;
- }
- else if (cc > 1200 && cc < 1401)
- {
- rtax = 140;
- }
- else if (cc > 1400 && cc < 1601)
- {
- rtax = 180;
- }
- else if (cc > 1600 && cc < 1801)
- {
- rtax = (1800 - cc)*0.8 + 400;
- }
- else if (cc > 1800 && cc < 2001)
- {
- rtax = (2000 - cc)*1.0 + 560;
- }
- else if (cc > 2000 && cc < 2501)
- {
- rtax = (2500 - cc)*3.0 + 760;
- }
- else if (cc > 2500 && cc < 3001)
- {
- rtax = (3000 - cc)*7.5 + 2260;
- }
- else if (cc > 3001)
- {
- rtax = (cc-3000)*13.5 + 6010;
- }
- else
- {
- printf("oops, thing went wrong !");
- rtax = 0.0;
- }
- printf("\nYour payable amount for road tax is : %.2f\n", rtax);
- system("pause");
- }
- else
- {
- printf("Invalid Choice !!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement