Just trying to clean it up (java) -
// "ch_1_summative" class. public static void main (string[] args) { c = new console (40,60); c.settextcolor(color.red); c.println( "baker bob's"); c.settextcolor(color.black); c.println( "73 little bridge st."); c.println(" almonte, ont."); c.println(" k0a 1a0"); c.println("(613) 256-7674"); c.println("____________________________________"); c.println(""); c.println(" items"); c.print("2 muffins $"); c.println(2*1.25,1,2); c.println("chicken simosa $1.60"); c.println("coupon #: 3265"); c.println("coupon value: -25%"); c.print("new price $"); c.println(.75*1.60,1,2); c.println("dipping sauce $0.50"); c.print("3 squares $"); c.println(3*1.40,2,2); c.println("white choclate cookies $4.75"); c.println("baguette $3.50"); c.println(""); c.print("sub-total: $"); c.println(2.50+1.20+.50+4.20+4.75+3.50); c.settextcolor(color.blue); c.print("hst: $"); c.println(.13*16.65,4,2); c.settextcolor(color.black); c.println("____________________________________"); c.settextcolor(color.red); c.print("total: $"); c.println(1.13*16.65,4,2); c.settextcolor(color.black); c.println(""); c.println("____________________________________"); c.println(" payment"); c.println("type: mastercard"); c.println("card number: 153-596-231"); c.println("verified by: pin"); c.println("____________________________________"); c.println("date: feb. 9, 2015"); c.println("receipt #: 3293071437"); c.println("cashier: jacob");
i'm complete noob programming (as in been doing 3 days) , when run on "ready program" application creates receipt fake restaurant. showed teacher , said "messy code", there way clean up, keep simple, have same product? ny awesome!!!
i think teacher means instead of having bunch of string outputs, should build more general-use program. example, make items
class, contain every item , price , quantity, , if coupons available. then, make array of items , have program go through array , output of items , prices. program should calculate total using array and, added bonus, generate random values else (receipt #, etc).
Comments
Post a Comment