XLnTz
XLnTz
CC#
Created by XLnTz on 11/18/2023 in #help
Converting int to double to output with decimals
Hello again! i got a little problem with converting int to double, i dont get it to output the decimals and i dont know where i do wrong ^^ Any tips?
public static void Main (string[] args)
{
double celsius = 0;
int fahr;

do
{
/*
+---------------------------+
| Here i input the integer! |
+---------------------------+
*/
Console.WriteLine("Write temp in fahrenheit: ");
fahr = int.Parse(Console.ReadLine());

celsius = FahrToCels(fahr);

Console.WriteLine("Your value in Celsius: " + celsius);
if (celsius < 82)
{
Console.WriteLine("Too Cold!");
}
else if (celsius > 87)
{
Console.WriteLine("Too Hot!");
}
} while (celsius < 82 || celsius > 87);
Console.WriteLine("Temp is ok! Enjoy!");

/*
+-------------------------------------+
| Here i want to output with decimals |
+-------------------------------------+
*/
Console.WriteLine("Fahrenheit: " + fahr);
Console.WriteLine("Celsius: " + celsius + "\n");
}

/*
+--------------------------------------------------------------------------------+
| Here i want to convert integer to double to output with decimals in code above |
+--------------------------------------------------------------------------------+
*/
public static double FahrToCels(int fahr)
{
double cel = (fahr - 32) * 5 / 9;
return cel;
}
public static void Main (string[] args)
{
double celsius = 0;
int fahr;

do
{
/*
+---------------------------+
| Here i input the integer! |
+---------------------------+
*/
Console.WriteLine("Write temp in fahrenheit: ");
fahr = int.Parse(Console.ReadLine());

celsius = FahrToCels(fahr);

Console.WriteLine("Your value in Celsius: " + celsius);
if (celsius < 82)
{
Console.WriteLine("Too Cold!");
}
else if (celsius > 87)
{
Console.WriteLine("Too Hot!");
}
} while (celsius < 82 || celsius > 87);
Console.WriteLine("Temp is ok! Enjoy!");

/*
+-------------------------------------+
| Here i want to output with decimals |
+-------------------------------------+
*/
Console.WriteLine("Fahrenheit: " + fahr);
Console.WriteLine("Celsius: " + celsius + "\n");
}

/*
+--------------------------------------------------------------------------------+
| Here i want to convert integer to double to output with decimals in code above |
+--------------------------------------------------------------------------------+
*/
public static double FahrToCels(int fahr)
{
double cel = (fahr - 32) * 5 / 9;
return cel;
}
160 replies
CC#
Created by XLnTz on 11/11/2023 in #help
✅ Need Help, Basic "lottery game"
Hello! im studying C# and got this project to make a "lottery game" that i have to complete until tomorrow and i cant get Matching number part to work. i need to Compare matching numbers from user and random and Print out users Numbers, Random Numbers and the matching numbers saying "Bingo Numbers: " and how many numbers are matching. Can anyone tell me how to make it work or guide how to add the matching numbers of users Array input and random numbers List? Here's the part if its any help (To much text with the whole code) //New list for Matching nr List<int> matchNum = new List<int>(); Console.WriteLine(); Console.Write("Bingo Numbers: "); //Loop to compare and add matching nr to matchNum and print each matching number as "Bingo" foreach (int num in rndList) { if (rndList.Contains(num)) { matchNum.Add(iNum); } if (matchNum.Count > 0) { Console.Write(matchNum.Count + ", "); }
81 replies