Thread: C# Programming With Mono
hi guys need bit of coding, cannot finish simple assignment program can me finish off please
here task:
bookstore has 3 books costing £9.99, £0.50 , £3.45.
add £2.50 postage.
give customer loyalty bonus subtracting £0.30p per book.
use variables values.
provide variable table , write code calculate total cost of books
here program , done far cant figure out how finish off:
// simple program calculates total cost of books
// namespace declaration
using system;
// program start class
class bookstore
{
// main begins program execution
public static void main()
{
/*
declaring 3 variables ( "book1" "book2" "book3" )
assigning data type ( "double" )
givining initial values ( "9.99" "0.50" "3.45" )
*/
double book1 = 9.99;
double book2 = 0.50;
double book3 = 3.45;
// using variable "loyalty bonus"
double loyaltybonus = 0.30;
double loyaltybonus = double.parse("0.30");
first of all, abt not place post programming homework help.
beyond that, haven't provided enough information you. specifically, how quantities of books purchased passed program? doubt you'd parsing command line arguments, it's possible.
anyway, like:
would return value given number of books of each type. pay more attention in class! trivial stuff should give no trouble if listen instructor.code:public static double totalcost(double count1, double count2, double count3) { double cost = 0; double book1 = 9.99; double book2 = 0.50; double book3 = 3.45; double loyaltybonus = 0.30; double postage = 2.50; cost = count1 * book1 + count2 * book2 + count3 * book3; cost -= loyaltybonus * (count1 + count2 + count3); cost += postage; return cost; }
Forum The Ubuntu Forum Community Ubuntu Official Flavours Support New to Ubuntu [ubuntu] C# Programming With Mono
Ubuntu
Comments
Post a Comment