module - PromptAndInput, cannot convert string into double (C#) -


greetings: new here, , i'm new writing code may not know do's , don'ts please bare me.

i'm having issues compiling program. errors have pointed promptandinput("any of text"); cannot implicitly convert string double

    name = promptandinput( "enter name of customer: ");     state = promptandinput( "in state (ny / nj / fl) ? ");      if (state != "nj" & state != "nj" & state != "ny" & state != "ny" & state != "fl" & state != "fl") {         console.writeline("error");         while (state != "nj" & state != "nj" & state != "ny" & state != "ny" & state != "fl" & state != "fl") {             state = promptandinput("in state (ny / nj / fl) ? ");         }     }      itemquantity = promptandinput("how many items purchased?: ");      if (itemquantity < 0) {         console.writeline("error");         while (itemquantity < 0) {             itemquantity = promptandinput("how many items purchased?: ");         }     }      itemprice = promptandinput("what unit price of items?: ");      if (itemprice < 0) {         console.writeline("error");         while (itemprice < 0) {             itemprice = promptandinput("what unit price of items?: ");         }     }      computetotal(itemquantity, itemprice, total, name);     computetax(state, total, itemquantity, itemprice); 

i'm sure easy spot, since i'm working modules i'm not sure how work around use of promptandinput

what can here?


after first fix

itemquantity = double.parse(promptandinput("how many items purchased?: "));

        if (itemquantity < 0)         {             console.writeline("error");             while (itemquantity < 0)             {                 itemquantity = double.parse(promptandinput("how many items purchased?: "));             }         }          itemprice = int.parse(promptandinput("what unit price of items?: "));          if (itemprice < 0)         {             console.writeline("error");             while (itemprice < 0)             {                 itemprice = int.parse(promptandinput("what unit price of items?: "));                    computetotal(itemquantity, itemprice, total, name);                 computetax(state, total, itemquantity, itemprice);              }         }     }  //function read , write public static string promptandinput(string prompt) {     string userinput = null;     console.write(prompt);     userinput = console.readline();     return userinput; }  //function total sales public static object computetotal(double itemquantity, int itemprice, double total, string name) {      total = itemquantity * itemprice;     console.writeline();     console.writeline("--------------------------------------------------");     console.writeline("the total sales " + name + " are: " + total);      return total; } 

the code suppose continue after

itemprice = int.parse(promptandinput("what unit price of items?: "));

not sure whats causing end

the return promptandinput string

public static string promptandinput(string prompt) 

so in code call this, need parse returned text:

itemquantity = int32.parse(promptandinput("how many items purchased?: "));  itemprice = double.parse(promptandinput("what unit price of items?: ")); 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -