# Double Trouble... C#

**URL:** <https://forum.kirupa.com/t/double-trouble-c/243840>\
**Category:** Uncategorized\
**Created:** [November 11, 2007, 7:06pm UTC](https://forum.kirupa.com/t/double-trouble-c/243840 "2007-11-11T19:06:51Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![zantetsuken](https://avatars.discourse-cdn.com/v4/letter/z/ebca7d/32.png) [@zantetsuken](https://forum.kirupa.com/u/zantetsuken)\
**Post date:** [November 11, 2007, 7:06pm UTC](https://forum.kirupa.com/t/double-trouble-c/243840/1 "2007-11-11T19:06:51Z")

</div>

Hopefully someone can help me quick. I am in a bind. I have been trying to figure out how to output 2 decimal places for score1, score2 and avg in the code below. So far everything I do ends up with an error of some kind. The user is allowed to enter the test score as a decimal and then an average is calculated that also needs to be in decimal form. The only thing I can get to display as a decimal is avg and it only has one decimal place even when the answer should have 2.

```auto
[SIZE=2][COLOR=#0000ff]
using[/COLOR][/SIZE][SIZE=2] System;
[/SIZE][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]class[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#2b91af]TestScoreAverage
[/COLOR][/SIZE][SIZE=2]{
[/SIZE][SIZE=2][COLOR=#0000ff]public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]static[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]void[/COLOR][/SIZE][SIZE=2] Main()
{
[/SIZE][SIZE=2][COLOR=#0000ff]int[/COLOR][/SIZE][SIZE=2] testscore1, testscore2, testscore3, testscore4, testscore5;
[/SIZE][SIZE=2][COLOR=#0000ff]string[/COLOR][/SIZE][SIZE=2] name;
[/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Enter the Student's name"[/COLOR][/SIZE][SIZE=2]);
name = [/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].ReadLine();
[/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Please enter {0}'s first test score"[/COLOR][/SIZE][SIZE=2],name);
testscore1 = [/SIZE][SIZE=2][COLOR=#2b91af]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#2b91af]Double[/COLOR][/SIZE][SIZE=2].Parse([/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].ReadLine()));
[/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"Please enter {0}'s second test score"[/COLOR][/SIZE][SIZE=2],name);
testscore2 = [/SIZE][SIZE=2][COLOR=#2b91af]Convert[/COLOR][/SIZE][SIZE=2].ToInt32([/SIZE][SIZE=2][COLOR=#2b91af]Double[/COLOR][/SIZE][SIZE=2].Parse([/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].ReadLine()));
[/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] score1 = ([/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2])testscore1;
[/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] score2 = ([/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2])testscore2;
[/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] sum = ([/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2])score1 + ([/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2])score2;
[/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2] avg = ([/SIZE][SIZE=2][COLOR=#0000ff]double[/COLOR][/SIZE][SIZE=2])sum / 5;
[/SIZE][SIZE=2][COLOR=#2b91af]Console[/COLOR][/SIZE][SIZE=2].WriteLine([/SIZE][SIZE=2][COLOR=#a31515]"{0} test scores are as follows: {1},{2} and the average is {3}"[/COLOR][/SIZE][SIZE=2], name, score1, score2, avg);
}
}
[/SIZE]

```
