Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Login
Sign Up
Ask Question
3
Reply
Program that adds input numbers until user inputs "0"
Song Lee
Sep 24 2014 7:05 PM
931
Reply
Hello again, C# corner users!
I need to make a program that will add numbers that user inputs, until user inputs 0.
It should look like this at the end:
----------------------------------------------------
[Summation of Real numbers]
Write 0 to Finish
Write an amount to sum or 0 to finish:
50
Write an amount to sum or 0 to finish:
40
Write an amount to sum or 0 to finish:
10.5
Write an amount to sum or 0 to finish:
0
The sum is :
100.5
----------------------------------------------------
Below are the outlines that I got so far:
Thanks for your help guys!
public class
FloatNumbersWhileAdd
{
private double
sum;
public void
Start()
{
WriteProgramInfo();
ReadInputAndSumNumbers();
ShowResults();
}
private void
WriteProgramInfo()
{
//
Coding part here
}
private void
ReadInputAndSumNumbers()
{
bool
done =
false;
while
(!done)
{
//
Coding part here
}
}
private double
ReadInput()
{
Console
.Write("
Write an amount to sum or zero to finish
: ");
double
num =
double
.Parse(
Console
.ReadLine());
return
num;
}
private void
ShowResults()
{
// Coding part here
}
}
}
Upload Source Code
Select only zip and rar file.
Post
Reset
Cancel
Answers (
3
)
Next Recommended Forum
C# Topics
What is the code to copy a file to a system32 folder