my problem is to convert this code into function....could someone help me to solve these problem..??? - #include <stdlib.h>
-
#include <stdio.h>
-
#include <ctype.h>
-
-
main()
-
{
-
int n, N, year, choice = 0;
-
float val, value, deprec, tag;
-
char answer1 = 'Y', answer2 = 'Y';
-
-
while(toupper(answer1) != 'N')
-
{
-
system("CLS");
-
-
if(toupper(answer2) != 'N')
-
{
-
printf("\nOriginal value: ");
-
scanf("%f", &value);
-
printf("Number of years: ");
-
scanf("%d", &N);
-
}
-
printf("\nMethod: (1-SL 2-DDB 3-SYD) ");
-
scanf("%d", &choice);
-
-
val = value;
-
n = N;
-
-
switch(choice)
-
{
-
case 1:
-
printf("\nStraight Line Method\n\n");
-
deprec = val/n;
-
for (year = 1; year <= n; ++year)
-
{
-
val -= deprec;
-
printf("End of year %2d ", year);
-
printf("Depreciation: %7.2f ", deprec);
-
printf("Current value:%8.2f\n", val);
-
}
-
break;
-
case 2:
-
printf("\nDouble Declining Balance Method\n\n");
-
for (year = 1; year <= n; ++year)
-
{
-
deprec = 2*val/n;
-
val -= deprec;
-
printf("End of year %2d ", year);
-
printf("Depreciation: %7.2f ", deprec);
-
printf("Current value:%8.2f\n", val);
-
}
-
break;
-
case 3:
-
printf("\nSum-of-the-Years\'-Digits method\n\n");
-
tag = val;
-
for (year = 1; year <= n; ++year)
-
{
-
deprec = (n-year+1)*tag/(n*(n+1)/2);
-
val -= deprec;
-
printf("End of year %2d ", year);
-
printf("Depreciation: %7.2f ", deprec);
-
printf("Current value:%8.2f\n", val);
-
}
-
break;
-
default: printf("NOT A VALID CHOICE");
-
}
-
printf("\n\nAnother calculation? [Y/N] ");
-
scanf("%1s", &answer1);
-
if(toupper(answer1) != 'N')
-
{
-
printf("Enter a new set of data? [Y/N] ");
-
scanf("%1s", &answer2);
-
}
-
-
}
-
printf("\nNormal Termination... ");
-
-
system("PAUSE");
-
}
please help me to solve this problem...,.thank you...
1 1531 Banfa 9,065
Expert Mod 8TB
It's already in a function, main(). You need to be more precise about which bit of the code needs to be in a separate function.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Peter Kwan |
last post by:
Hi,
I believe I have discovered a bug in Python 2.3. Could anyone suggest a get around?
When I tested my existing Python code with the newly released Python 2.3, I get the following warning:
...
|
by: Eric Lilja |
last post by:
Hello, I've made a templated class Option (a child of the abstract base
class OptionBase) that stores an option name (in the form someoption=) and
the value belonging to that option. The value is...
|
by: Rodusa |
last post by:
I am having problem to apply updates into this function below. I tried
using cursor for updates, etc. but no success. Sql server keeps telling
me that I cannot execute insert or update from inside...
|
by: Charles Law |
last post by:
I thought this was going to be straight forward, given the wealth of
conversion functions in .NET, but it is proving more convoluted than
imagined.
Given the following
<code>
Dim ba(1) As...
|
by: patang |
last post by:
I want to convert amount to words. Is there any funciton available?
Example:
$230.30
Two Hundred Thirty Dollars and 30/100
|
by: patang |
last post by:
Could someone please tell me where am I supposed to put this code. Actually
my project has two forms. I created a new module and have put the following
code sent by someone. All the function...
|
by: Learner |
last post by:
Hello,
Here is the code snippet I got strucked at.
I am unable to convert the below line of code to its equavalent vb.net
code. could some one please help me with this?
static public...
|
by: Edwin Knoppert |
last post by:
In my code i use the text from a textbox and convert it to a double value.
I was using Convert.ToDouble() but i'm used to convert comma to dot.
This way i can assure the text is correct.
However...
|
by: dba_222 |
last post by:
Dear Experts,
Ok, I hate to ask such a seemingly dumb question, but I've
already spent far too much time on this. More that I
would care to admit.
In Sql server, how do I simply change a...
|
by: ballygowanboy |
last post by:
ok, so i've my front end shop code almost working, the quantity and price all add up........ now i need to add a curency conversion function, euro (default), dollar, and uk pound.
right, i'm not...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
| |