Need help to see what I put in the array!


hello!

i have problem program. it´s assignment school can not figure out problem is. program sodacrate, , supposed put sodas in sodacrate. made count price, working.  and loop stops after 25 times, , supposed able put in 25 sodas. doesn´t work when supposed able choose see have put in crate. 

it demand crate array, not list. have been doing methods (i think it´s called) it´s bit messy. i´m gonna paste whole thing , maybe me see wrong. 

i´m gonna make arrow can see in menu can choose see in crate, since things written in swedish. 

hopefully can tell me wrong! thank you.

 class program      {          private static int amountbottles = 0; //håller reda på antal flaskor          private static int totalprice = 0; //håller reda på det totala priset          public static string[] bottles = new string[25]; //läskbacks-vektorn          private static int choicesoda;          public static string cocacola;          public static string fanta;          public static string ramlösa;          public static string trocadero;           public static void addbottle() //metod: addbottle, för att lägga till läsk vektorn          {              (int = 0; < bottles.length; i++)              {                    if (choicesoda == 1)  //om valet är fanta                  {                      bottles[i] = fanta;                      console.writeline("fanta");                      console.readkey();                  }                        if (choicesoda == 2) //om valet är cola                      {                          bottles[i] = cocacola;                          console.writeline("coca cola");                        }                      if (choicesoda == 3)  //om valet är ramlösa                      {                          bottles[i] = ramlösa;                          console.writeline("ramlösa");                        }                      if (choicesoda == 4) //om valet är trocadero                      {                          bottles[i] = trocadero;                          console.writeline("trocadero");                        }                  }              }                                              private static void addbottlemenu()  //metod: addbottlemenu, menyn för att lägga till läsk          {                                           {                  console.writeline("välj en av följande läsksorter: ");                  console.writeline("[1]fanta        5kr");                  console.writeline("[2]coca cola    5kr");                  console.writeline("[3]ramlösa      5kr");                  console.writeline("[4]trocadero    5kr");                    int choicesoda = int.parse(console.readline());                  switch (choicesoda)                  {                        case 1:                            addbottle();                          amountbottles++;                          totalprice = totalprice + 5;                          break;                        case 2:                            addbottle();                          amountbottles++;                          totalprice = totalprice + 5;                          break;                        case 3:                            addbottle();                          amountbottles++;                          totalprice = totalprice + 5;                          break;                        case 4:                            addbottle();                          amountbottles++;                          totalprice = totalprice + 5;                          break;                        default:                          console.writeline("ogiltigt val, försök igen");                          break;                    }              } while (amountbottles < 25);            }            static void main(string[] args)          {                              int loopis = 4;              while (loopis == 4)              {                  console.writeline("*~~*~~*~~*~~*~~*~~*~~*~~vÄlkommen~~*~~*~~*~~*~~*~~*~~*~~*");                  console.writeline("i detta program kan du fylla upp din egna läskback.");                  console.writeline("var vänlig och välj ett av följande alternativ:");                  console.writeline("1. lägga till en läsk till backen.");                  console.writeline("2. se det totala priset.");                  console.writeline("3. se backens innehåll.");   //here option <-------------                  console.writeline("4. jag är nöjd och vill avsluta.");                  console.writeline("*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*~~*");                    int choicefirst = int.parse(console.readline());                  switch (choicefirst)                  {                      case 1:                          console.write("du valde att lägga till läsk backen.");                          addbottlemenu();                            break;                      case 2:                          console.write("du valde att se hur mycket läskbacken kostar.");                          console.writeline(" läskbacken kostar nu: ");                          console.writeline(totalprice + " kronor"); //skriver ut det totala priset                          break;                      case 3:                          console.writeline("du valde att se vad som finns backen nu.");                          (int =0; i<bottles.length;i++)                          {                              console.writeline( bottles[i] );                          }                          break;                      case 4:                          console.writeline("kul att du är nöjd, välkommen åter! :)");                          loopis++;                          break;                      default:                          console.writeline("ogiltigt val, försök igen.");                          break;                  }              }              console.readkey();          }      }  }

hi konrad!

i have been changing many things , tried many different things. got work! can´t did right, apparently did right :d

i want thank alot help!

thank guys!



Visual Studio Languages  ,  .NET Framework  >  Visual C#



Comments

Popular posts from this blog

Azure DocumentDB Owner resource does not exist

job syspolicy_purge_history job fail in sqlserver 2008

Trying to register with public marketplace error with 'Get-AzureStackStampInformation'