0

why this code fails 4th test case on hovercraft code coach?

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { long hovercraft = Convert.ToInt64(Console.ReadLine()); long cost = 2000000; long allcost = cost * hovercraft; long sell = 3000000; long allsold = sell * hovercraft; long all = (allsold - allcost) - 1000000; if (all >= 7000000) { Console.WriteLine("Profit"); } else if (all < 0) { Console.WriteLine("Loss"); } else { Console.WriteLine("Broke Even"); } } } }

24th Dec 2022, 9:41 PM
ThepPretzel
ThepPretzel - avatar
4 Réponses
+ 2
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Sololearn { class Program { static void Main(string[] args) { long hovercraft = Convert.ToInt64(Console.ReadLine()); long cost = 2000000; long allcost = cost * 10; long sell = 3000000; long allsold = sell * hovercraft; long all = (allsold - allcost) - 1000000; if (all >0) { Console.WriteLine("Profit"); } else if (all < 0) { Console.WriteLine("Loss"); } else { Console.WriteLine("Broke Even"); } } } }
25th Dec 2022, 3:03 AM
Lwez
Lwez - avatar
+ 1
int makesInMonth=10; int insurance=1000000; int selling=3000000; int build=2000000; int a =Convert.ToInt32(Console.ReadLine()); if(a*selling>makesInMonth*build+insurance){ Console.WriteLine("Profit"); }else if(a*selling==makesInMonth*build+insurance){ Console.WriteLine("Broke Even"); }else{ Console.WriteLine("Loss"); }
25th Dec 2022, 2:57 AM
Lwez
Lwez - avatar
0
yeah very bad naming i know
24th Dec 2022, 9:42 PM
ThepPretzel
ThepPretzel - avatar
0
broke even is not only zero. it's between zero and 6 million~ i think. i done something now code fails 5th case
25th Dec 2022, 4:01 AM
ThepPretzel
ThepPretzel - avatar