0% found this document useful (0 votes)
13 views10 pages

CSC 201 Assignment Ademola Adetunji David

The document contains a series of C++ programming assignments for a Computer Science course, including tasks such as calculating data usage, call costs, future investment values, and the area of a circle. Each task is accompanied by sample C++ code that demonstrates how to implement the required functionality. Additionally, it includes a program to illustrate the ASCII table and a simple code snippet to display a variable.

Uploaded by

myqhtsc6jf
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)
13 views10 pages

CSC 201 Assignment Ademola Adetunji David

The document contains a series of C++ programming assignments for a Computer Science course, including tasks such as calculating data usage, call costs, future investment values, and the area of a circle. Each task is accompanied by sample C++ code that demonstrates how to implement the required functionality. Additionally, it includes a program to illustrate the ASCII table and a simple code snippet to display a variable.

Uploaded by

myqhtsc6jf
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/ 10

NAME:ADETUNJI ADEMOLA DAVID

COURSE : CSC 201


DEPARTMENT : COMPUTER SCIENCE
GROUP: ONE
LEVEL: 200
MATRIC : 22/11436

ASSIGNMENT QUESTIONS
1) *1.are on 3K one off, expires 05/12/2023, 13:00am your data balance is 5905mb and browse
for 1062 mins write a c++ program to implement

C++ code
#include <iostream>
#include <iomanip>

struct DataUsage {
int initialDataBalance;
int dataUsedPerMinute;
};

// Function to calculate data usage


int calculateDataUsage(const DataUsage& usage, int browseDuration) {
return browseDuration * usage.dataUsedPerMinute;
}

int main() {
DataUsage usage = {3000, 5}; // Initial data balance and data used per minute
int dataBalance = 5905; // in megabytes
int browseDuration = 1062; // in minutes

// Calculate data usage


int dataUsed = calculateDataUsage(usage, browseDuration);

// Calculate remaining data balance


int remainingData = dataBalance - dataUsed;

// Display results
std::cout << "Initial data balance: " << usage.initialDataBalance << " MB" << std::endl;
std::cout << "Data used during browsing: " << dataUsed << " MB" << std::endl;
std::cout << "Remaining data balance: " << remainingData << " MB" << std::endl;

return 0;
}
2.Your last call was 18 seconds at #6.06 include VAT, new balance is 1869.92. Write a C++ program to
implement this

Code:

#include <iostream>
using namespace std;
int main() {
double currentBalance = 1869.92;
int callDuration = 18;
double callRate = 6.06;
double vat = 0.06;

double callCost = callDuration * callRate * (1 + vat);


double newBalance = currentBalance - callCost;

cout << "New balance after the call: $" << newBalance << endl;

return 0;
}
3. Your course rep by name "Mary" has just deposited the sum of 100,000 in her current account,
Caleb University Assuming that 10% interest is compounded annually, earned on that amount, how
much is due to her at the end of 5 years.
Hint :
1) Present value is requested to be compounded
i) Future value is unknown
Write a c++ Value to assist Mary future value of her investment in her Current account

Code:
#include <iostream>
#include <cmath>

int main() {
// Present Value
double PV = 100000.0;

// Annual interest rate


double interestRate = 0.10;

// Number of years
int years = 5;

// Calculate future value


double FV = PV * pow(1 + interestRate, years);

// Display the result


std::cout << "The future value after " << years << " years is: " << FV << std::endl;

return 0;

}
4.4.Mr Obafemi is an undergraduate computer science in Caleb University and his roomate ask him
to help him find out how much he will earn at the end of 4 yrs if he deposit N100,00 annually in my
bank witch pays 4% per annum Write a C+ program to assist your course mate

Code

#include <iostream>
#include <cmath>

struct Investment {
double annualDeposit;
double interestRate;
};

// Function to calculate future value


double calculateFutureValue(const Investment& investment, int years) {
double futureValue = 0;
for (int i = 0; i < years; ++i) {
futureValue += investment.annualDeposit * pow(1 + investment.interestRate, i + 1);
}
return futureValue;
}

int main() {
Investment investment = {100000.0, 0.04}; // in Naira and 4% interest rate
const int years = 4;

// Calculate future value


double futureValue = calculateFutureValue(investment, years);

// Display the result


std::cout << "The future value after " << years << " years is: " << futureValue << " Naira" <<
std::endl;

return 0;
}
5.:write a c++ program to calculate the area of a circle

Code:
#include <iostream>
#include <cmath>

using namespace std;

int main()
{ double radius, area;
//Get the radius from the user
cout << "enter the radius of the circle: ";
cin >> radius;

//calculate the area of the circle


area = M_PI * pow(radius, 2);

//display the result


cout << "The area of the circle is: " << area << endl;
return 0;
}

6) Using C++ to illustrate ASCII TABLE

Code
#include <iostream>
#include <iomanip>

int main() {
// Print the header
std::cout << std::setw(5) << "Dec" << std::setw(5) << "Char" << std::setw(5)
<< "Hex" << std::setw(5) << "Oct" << std::endl;

// Print the ASCII table


for (int i = 32; i < 128; ++i) {
std::cout << std::setw(5) << i << std::setw(5) << static_cast<char>(i) <<
std::hex << std::setw(5) << i << std::oct << std::setw(5) << i << std::dec <<
std::endl;
}
return 0;
}

7) write simple code n = 20


#include <iostream>
using namespace std;

int main() {
int n = 20;
cout << "n = " << n << endl;
return 0;
}

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy