0% found this document useful (0 votes)
5 views

PROGRAMMING ASSIGNMENT

The document contains multiple programming assignments written in C++ that involve user input for financial calculations. Key functionalities include loan approval based on credit score and income, transaction fees based on membership type and transaction amount, and tax calculations based on earnings and transaction count. Each question presents a different scenario requiring conditional logic to determine outputs.

Uploaded by

fawaz.qazi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PROGRAMMING ASSIGNMENT

The document contains multiple programming assignments written in C++ that involve user input for financial calculations. Key functionalities include loan approval based on credit score and income, transaction fees based on membership type and transaction amount, and tax calculations based on earnings and transaction count. Each question presents a different scenario requiring conditional logic to determine outputs.

Uploaded by

fawaz.qazi4
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

PROGRAMMING ASSIGNMENT

QUESTION 1:
#include <iostream>
using namespace std;
int main (){
int cs;
float ai, ed, lr;
cout<<"Enter your credit score"<<endl;
cin>>cs;

cout<<"Enter your annual income"<<endl;


cin>>ai;

cout<<"Enter your existing debt"<<endl;


cin>>ed;

cout<<"How much loan are you requesting"<<endl;


cin>>lr;

if (cs > 700 and ai>=3*lr){


cout<<"Your loan amount is approved"<<endl;
}
else if (cs>= 600 and cs<=700){
if (ai>=5*lr and ed <=0.5*ai){
cout<<"Your loan amount is approved"<<endl;
}
else {
cout<<"Your loan is not approved"<<endl;
}

}
else if (cs < 600) {
cout<<" Your loan is rejected"<<endl;
}
else if (lr>ai){
cout<<"Your loan is rejected"<<endl;
}
return 0;
}

QUESTION 2:
#include <iostream>
#include <string>
using namespace std;
int main(){
float ta, time;
string membership;
cout<<"Enter trade amount"<<endl;
cin>>ta;
if (ta > 10000){
cout<<"What membership do you have (Premium/Regular)?"<<endl;
cin>>membership;
if (membership == "Premium" or membership == "premium"){
cout<<"Flat fee is 2%"<<endl;
ta = ta * 0.02;
cout<<"Amount of fee = "<< ta<<endl;
}
else if(membership == "Regular" or membership == "regular") {
cout<<"Flat fee is 3%"<<endl;
ta = ta * 0.03;
cout<<"Amount of fee = "<< ta<<endl;
}
}
if (ta >=1000 and ta <=10000){
cout<<"What membership do you have (Premium/Regular)?"<<endl;
cin>>membership;
cout<<"For how many years have you been a user"<<endl;
cin>>time;
if (membership== "Regular" or membership == "regular") {
cout<<"Flat fee is 4%"<<endl;
ta = ta * 0.04;
cout<<"Amount of fee = "<< ta<<endl;
}
else if (time>5){
cout<<"Flat fee is 2%"<<endl;
ta = ta * 0.02;
cout<<"Amount of fee = "<< ta<<endl;
}
}
else if (ta < 1000) {
cout<<"Flat fee is 5%"<<endl;
ta = ta * 0.05;
cout<<"Amount of fee = "<< ta<<endl;
}
return 0;
}

QUESTION 3:
#include <iostream>
using namespace std;

int main() {
int baseCount, finalCount, index, extraCount;
cout << "Enter the initial number of transactions: ";
cin >> baseCount;
cout << "Enter the number of additional transactions: ";
cin >> extraCount;

finalCount = baseCount;
for (index = 0; index < extraCount; index++) {
if (index % 2 == 0) {
finalCount++;
} else {
++finalCount;
}
}

double totalCost = 0.0;


if (finalCount <= 10) {
totalCost = finalCount * 2.0;
} else {
totalCost = 10 * 2.0 + (finalCount - 10) * 1.80;
}

cout << "Total number of transactions: " << finalCount << endl;
cout << "Total transaction fee: $" << totalCost << endl;

return 0;
}

QUESTION 4:
#include <iostream>
using namespace std;

int main() {
int ratingScore;
float yearlyEarnings, currentDebt, requestedLoan;

cout << "Enter your credit score" << endl;


cin >> ratingScore;

cout << "Enter your annual income" << endl;


cin >> yearlyEarnings;

cout << "Enter your existing debt" << endl;


cin >> currentDebt;

cout << "How much loan are you requesting" << endl;
cin >> requestedLoan;
if (ratingScore > 700 and yearlyEarnings >= 3 * requestedLoan) {
cout << "Your loan amount is approved" << endl;
}
else if (ratingScore >= 600 and ratingScore <= 700) {
if (yearlyEarnings >= 5 * requestedLoan && currentDebt <= 0.5 * yearlyEarnings) {
cout << "Your loan amount is approved" << endl;
} else {
cout << "Your loan is not approved" << endl;
}
}
else if (ratingScore < 600) {
cout << "Your loan is rejected" << endl;
}
else if (requestedLoan > yearlyEarnings) {
cout << "Your loan is rejected" << endl;
}

return 0;
}

QUESTION 5:
#include <iostream>
using namespace std;

int main() {
float netEarnings, tradeCount;

cout << "Enter profit earned" << endl;


cin >> netEarnings;

cout << "Enter number of transactions made" << endl;


cin >> tradeCount;

if (netEarnings < 10000 and tradeCount <= 20) {


cout << "Tax imposed is 0%" << endl;
}
else if (tradeCount > 20 and netEarnings < 10000) {
cout << "Tax imposed is 2%" << endl;
}
else if (netEarnings >= 10000 and netEarnings <= 50000) {
if (tradeCount <= 20) {
cout << "Tax imposed is 15%" << endl;
} else {
cout << "Tax imposed is 17%" << endl;
}
}
else if (netEarnings > 50000 and netEarnings <= 100000) {
if (tradeCount <= 20) {
cout << "Tax imposed is 25%" << endl;
} else {
cout << "Tax imposed is 27%" << endl;
}
}
else if (netEarnings > 100000) {
if (tradeCount <= 20) {
cout << "Tax imposed is 35%" << endl;
} else {
cout << "Tax imposed is 37%" << endl;
}
}

return 0;
}
QUESTION 6:
#include <iostream>
#include <string>
using namespace std;

int main() {
float transactionValue, userDuration;
string accountType;

cout << "Enter trade amount" << endl;


cin >> transactionValue;

if (transactionValue > 10000) {


cout << "Enter your membership type" << endl;
cin >> accountType;

if (accountType == "premium") {
cout << "Flat fee will be 2%" << endl;
transactionValue = transactionValue * 0.02;
cout << "Amount of fee is " << transactionValue << endl;
}
else if (accountType == "regular") {
cout << "Flat fee will be 3%" << endl;
transactionValue = transactionValue * 0.03;
cout << "Amount of fee is " << transactionValue << endl;
}
}

if (transactionValue >= 1000 and transactionValue <= 10000) {


cout << "Enter your membership type" << endl;
cin >> accountType;
cout << "For how many years have you been a user" << endl;
cin >> userDuration;

if (accountType == "regular") {
cout << "Flat fee will be 4%" << endl;
transactionValue = transactionValue * 0.04;
cout << "Amount of fee is " << transactionValue << endl;
}
else if (userDuration > 5) {
cout << "Flat fee will be 2%" << endl;
transactionValue = transactionValue * 0.02;
cout << "Amount of fee is " << transactionValue << endl;
}
}
else if (transactionValue < 1000) {
cout << "Flat fee will be 5%" << endl;
transactionValue = transactionValue * 0.05;
cout << "Amount of fee is " << transactionValue << endl;
}

return 0;
}
QUESTION 7:
#include <iostream>
using namespace std;

int main() {
float yearlyEarnings, ratingScore;

cout << "Enter your annual income" << endl;


cin >> yearlyEarnings;

cout << "Enter your credit score" << endl;


cin >> ratingScore;

if (ratingScore >= 700 or yearlyEarnings >= 50000) {


cout << "Loan Approved" << endl;
}
else {
cout << "Loan Denied" << endl;
}

return 0;
}

QUESTION 8:
#include <iostream>
#include <string>
using namespace std;

int main() {
float transactionValue;
string accountCategory;

cout << "Enter your transaction amount" << endl;


cin >> transactionValue;

cout << "Enter account type" << endl;


cin >> accountCategory;

if (transactionValue >= 10000 or accountCategory == "flagged") {


cout << "Suspicious Transaction Detected" << endl;
}
else {
cout << "Transaction Approved" << endl;
}

return 0;
}

QUESTION 9:
#include <iostream>
#include <cmath>
using namespace std;

int main() {
int transferAmount;

cout << "Enter the amount you want to transfer" << endl;
cin >> transferAmount;

if (transferAmount % 100 == 0) {
cout << "Transaction fee is 2%" << endl;
transferAmount = transferAmount * 0.02;
cout << "Fee amount is " << transferAmount << endl;
}
else {
cout << "Transaction fee is 3%" << endl;
transferAmount = transferAmount * 0.03;
cout << "Fee amount is " << transferAmount << endl;
}

return 0;
}

You might also like