Supplementary Assignment Release time Sunday, 21 Nov2021 at 12:00AM Due date Thursday, 25Nov2021 at 11:59PM This assignm
Posted: Sat Nov 27, 2021 2:43 pm
Test Cases Test 1 prices: (25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000, 25000, 10000}, size: 10, order: 3 Returned result must be: 25000 Test 2 prices: (25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000, 25000, 10000}, size: 10, order: 5 Returned result must be: 29499 Test 3 prices: <25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000, 25000, 10000}, size: 10, order: 4 Returned result must be: 29000 Test 4 prices: (25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000, 25000, 10000}, size: 10, order: 7 Returned result must be: -1 (there is no 7th lowest price. There are only 5 prices available) Test 5 prices: (25000, 20000}, size: 2, order: 2 Returned result must be: 25000 . Test 6 prices: (25000, 20000), size: 2, order: 3 Returned result must be: -1 (there are only 2 prices, and therefore, there is no 3rd lowest price) Test 7 prices: <20000}, size: 1, order: 1 Returned result must be: 20000 Test 8 prices: {10000, 20000, 25000, 29499}, size: 4, order: 2 Returned result must be: 20000 Test 9 prices: {10000, 20000, 25000, 29499}, size: 4, order: -5 Returned result must be: -1 (the order is not valid, and therefore, unable to find a lowest price)
#include<stdio.h> #include "PUT_YOUR_STUDENT_ID_HERE.h" // your file must be named as such and exsits in same folder of this file void oracle(int no, int array[], int size, int order, int expected, int actual) { printf("Test $d: \n\t\tPrices: {",no); for (int i = 0; i < size; i++) { printf(" %d ", array); } printf("}\n\t\tOrder: %d", order); printf("\n\t\tExpected result: %d", expected); printf("\n\t\tYour function result: %d", actual); printf("\n\t\tStatus: %s\n", expected==actual?"passed":"failed"); } , 25000 10000); int main() { 11 oracles int tests = 0; int testAl[ ] = { 25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000 int orderl = 3; int resl = 25000; int resA = lowestPrice(testAl,sizeof(testAl)/sizeof(int), orderl); oracle(1, testAl, sizeof(testAl)/sizeof(int), orderl, resl, resA); if(res le=resA) tests++; 25000, 10000 }; int testA2[] = { 25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000 int order2 = 5; int res2 = 29499; resA = lowestPrice(testA2, sizeof(testA2)/sizeof(int), order2); oracle(2, testA2, sizeof(testA2)/sizeof(int),order2, res2, resA); if(res2==resA) tests++; int testA3[] = { 25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000 ,25000, 10000 }; int order3 = 4; int res3 = 29000; resA = lowestPrice(testA3, sizeof(testA3)/sizeof(int), order3); oracle(3, testA3, sizeof(testA3)/sizeof(int),order3, res3, resA); if (res 3==resA) tests++; int testA4[] = { 25000, 20000, 29499, 10000, 20000, 29000, 25000, 20000 ,25000, 10000 }; int order4 = 7; int res4 = -1; resA = lowestPrice(testA4, sizeof(testA4)/sizeof(int), order4); oracle(4, testA4, sizeof(testA4)/sizeof(int),order4, res4, resA); if(res4==resA) tests++; int testA5() = {25000, 20000}; int order5 = 2; int res5 = 25000; resA = lowestPrice(testA5, sizeof(testА5)/sizeof(int),order5); oracle(5, testA5, sizeof(testА5)/sizeof(int),order5, res5, resA); if (res 5==resA) tests++; int testA6[] = {25000, 20000}; int order6 = 3;
= int testA7[] {20000}; int order7 = 1; int res7 = 20000; resA = lowestPrice(testA7, sizeof(testA7)/sizeof(int), order7); oracle (7, testA7, sizeof(testA7)/sizeof(int),order7, res7, resA); if(res 7==resA) tests++; int testA8[] {10000, 20000, 25000, 29499}; int order8 = 2; int res8 = 20000; resA = lowestPrice(testA8, sizeof(testA8)/sizeof(int), order8); oracle(8, testA8, sizeof(testA8)/sizeof(int),order8, res8, resA); if(res8==resA) tests++; int testA9[ ] = {10000, 20000, 25000, 29499}; int order9 = -5; int res9 = -1; resA = lowestPrice(testA9, sizeof(testA9)/sizeof(int),order9); oracle(9, testA9, sizeof(testA9)/sizeof(int),order9, res9, resA); if(res 9==resA) tests++; if(tests!=9) printf("\nYour implementation failed %d test(s).\n\n", (9-tests)); else printf ("Your implementation passed all tests. Excellent work.\n\n"); return 0; }
int lowestPrice (int prices[], int size, int order) { // write you code and implementation here } void myHelpFunction1(int param1) { } int myHelpFunction2 (int paramx) { return 0; }