SUPER SALE i did the example on my code it gave me the right answer i don't know where the bug is because my math is right | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

SUPER SALE i did the example on my code it gave me the right answer i don't know where the bug is because my math is right

https://code.sololearn.com/cVe7MC1FTpyt/?ref=app

2nd Jul 2022, 11:35 PM
Jakub Quinn
Jakub Quinn - avatar
11 Answers
- 1
I wrote my Code now you can see how I done it. https://code.sololearn.com/ccJTkC5oBWCC/?ref=app
3rd Jul 2022, 4:44 PM
Felix Alcor
Felix Alcor - avatar
+ 1
I didn't try it myself but that you Code don't Work let me belive that the Last 3 Test cases aren't Just 3 Elements. You Code's just for 3 elements but the Challenge say nothing about just 3 Elements. I would recommend you to try the List.Sort() Method to find out about the biggest payment and then calculate.
3rd Jul 2022, 12:38 AM
Felix Alcor
Felix Alcor - avatar
+ 1
Thank you so much its works great
3rd Jul 2022, 5:02 PM
Jakub Quinn
Jakub Quinn - avatar
0
I get the first 3 ones right but fail the last three
2nd Jul 2022, 11:38 PM
Jakub Quinn
Jakub Quinn - avatar
0
I would Most likely do it Like that: List<double> list = new List<double>(); string input; double discount = 0.7; double taxes = 1.07; input = Console.ReadLine(); foreach(string word in input.Split(',')) { double nums = Convert.ToDouble(word); list.Add(nums); } nums.Sort((a, b) => b.CompareTo(a)); int sumb = nums.Sum()*taxes; for(int i = 1; i < nums.Count; i++) { nums[i] *= discount; } Console.WriteLine(Math.Floor(sumb - nums.Sum()*taxes)); The Code is probably false but I hope the idea how it could be done goes through. :)
3rd Jul 2022, 12:54 AM
Felix Alcor
Felix Alcor - avatar
0
Thank youu i will give it a try
3rd Jul 2022, 12:59 AM
Jakub Quinn
Jakub Quinn - avatar
0
Nadhil An that have nothing to do with the question
4th Jul 2022, 5:30 PM
Felix Alcor
Felix Alcor - avatar
0
But its not working.it saws errors
4th Jul 2022, 5:31 PM
Nadhil An
Nadhil An - avatar
0
But that isn't a Code from this question.
4th Jul 2022, 5:39 PM
Felix Alcor
Felix Alcor - avatar
- 1
#include<stdio.h> int main(void) { int num1,num2; printf("enter two numbers"); scanf("%d%d",&num1,&num2); if(num1>number2){ printf("greater number is %d", number1); }else{ printf("greater number is %d", number2); } return 0; } What is the mistake on this?
4th Jul 2022, 5:14 PM
Nadhil An
Nadhil An - avatar
- 2
Cool
4th Jul 2022, 5:39 PM
Nadhil An
Nadhil An - avatar