Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

So here we have two problems different from each other. Both I would like to see

ID: 3537013 • Letter: S

Question

So here we have two problems different from each other. Both I would like to see be written in C#. I have most of the code for the first one written but need a little help (so I can compare). Thank you very much!



1. Write an application using object oriented principles (methods, etc.) that will enable a

vendor to see what earnings he can expect to make based on what percentage he marks up an

item. Allow the user to input the wholesale item price. In a tabular form, show the retail price

of the item marked up at 5%, 6%, 7%, 8%, 9%, and 10%.


2. Write this program using two different control structures - an IF statement and a SWITCH

statement.


A large Internet provider determines its shipping charges based on the number of items

purchased. As the number increases, the shipping charges proportionally decrease in order to

encourage more purchasing. If a single item is purchased, the shipping charge is $2.99. When

customers purchase between 2 and 5 items, they are charged the initial $2.99 for the first item

and then $1.99 for the remaining items. For customers who purchase more than 5 items but

less than 15, they are charged the initial $2.99 for the first item, $1.99 per item for items 2

through 5, and $1.49 per item for the remaining items. If they purchase 15 or more items they

are charged the initial $2.99 for the first item, $1.99 for items 2 through 5, and $1.49 per item

for items 6 through 14 and then just $0.99 per item for the remaining items. Allow the user to

enter the number of items purchased. Display the shipping charges.

Explanation / Answer

//FIRST PART

using System;

public class Test

{

public static void Main()

{

Test ob = new Test();

Console.WriteLine("Enter Wholesale item price:");

double n = double.Parse(Console.ReadLine());

Console.WriteLine("%Marked Up Retail Price");

Console.WriteLine("5% "+ob.rprice(n,5));

Console.WriteLine("6% "+ob.rprice(n,6));

Console.WriteLine("7% "+ob.rprice(n,7));

Console.WriteLine("8% "+ob.rprice(n,8));

Console.WriteLine("9% "+ob.rprice(n,9));

Console.WriteLine("10% "+ob.rprice(n,10));

}

public double rprice(double price,double percent)

{

return (((100+percent)/100)*price);

}

}


//SECOND PART

using System;

public class Test2

{

public static void Main()

{

Test2 ob = new Test2();

Console.WriteLine("Enter Number of items Puchased:");

int n = int.Parse(Console.ReadLine());

  

// using if-else

Console.WriteLine("Shipping charges for "+n+" items are: $"+ob.charges(n));

// using switch-case

Console.WriteLine("Shipping charges for "+n+" items are: $"+ob.charges2(n));

}

// if-else

public double charges(int n)

{

if(n==1)

{ return (2.99); }

else if(n>=2 && n<=5)

{ return (2.99 +((n-1)*1.99)); }

else if(n>5 && n<15)

{ return (2.99 + (4*1.99) +((n-5)*1.49)); }

else if(n>=15)

{ return (2.99 + (4*1.99) +(9*1.49)+((n-14)*0.99)); }

else

{

return 0; }

  

}

//using switch-case

public double charges2(int n)

{

switch(n)

{

case 0:

{return 0;

break;}

case 1:

{ return (2.99);

break;}

case 2:

case 3:

case 4:

case 5:

{ return (2.99 +((n-1)*1.99));

break; }

case 6:

case 7:

case 8:

case 9:

case 10:

case 11:

case 12:

case 13:

case 14:

{ return (2.99 + (4*1.99) +((n-5)*1.49));

break ;}

default :

{ return (2.99 + (4*1.99) +(9*1.49)+((n-14)*0.99));

break;}

}

  

}

  

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote