Hello,
I'm learning C++ and Dot Net and I hope this is the right forum. I'm very new to this game and I see to be having a little problem and was wondering if someone could shed some time.
The code below basicalyl asks a few questions (more will be added) and multiples the answer by the rate. What I want to do at the end is to add up all the results. So for example, TMB and TGB would be 5 each, so the total would be 10. But when I do it, it doesn't give me the right #. If TMB is 1.25 and TGB is 1.25, the answer should be 2.50, instead it reads out as 2. The error tells me that
warning C4244: '=' : conversion from 'double' to 'int', possible loss of data
I'm so lost on this part and if anyone could shed some light, i would be deeply appreciative.
Thanks
Code:void selectMenu(int option) { int mb=0; double tmb=0.0; int gb=0; double tgb=0.0; int sum=0; switch (option) { default: Console::WriteLine("Error"); case 1: Console::WriteLine("Megabytes?"); mb=Convert::ToInt32(Console::ReadLine()); tmb=mb*0.25; Console::WriteLine("{0}", Convert::ToString(tmb)); Console::WriteLine("Gigabytes?"); gb=Convert::ToInt32(Console::ReadLine()); tgb=gb*0.25; Console::WriteLine("{0}", Convert::ToString(tgb)); sum=tmb+tmb; Console::WriteLine("{0}", Convert::ToString(sum)); break; case 2: Console::WriteLine("This is option 2"); break; case 3: Console::WriteLine("This is option 3"); break; } }



LinkBack URL
About LinkBacks


