שאלה שטיחי דשא (גיא החלקאי.. דן הגנן):פתרון ב-Java...

שאלה שטיחי דשא (גיא החלקאי.. דן הגנן):

פתרון ב-Java:

int size =0;
int quantity = 0;

while( size<200 )
{
System.out.println("Please enter width and height:");
int w = reader.nextInt();
int h = reader.nextInt(); // or input.nextInt();
quantity++;
size=size+w*h;
}
System.out.println("The quantity is "+quantity+", the price is "+30*quantity);




פתרון ב-C#:

int size =0;
int quantity = 0;

while( size<200 )
{
Console.WriteLine("Please enter width and height:");
int w = int.Parse(Console.ReadLine());
int h = int.Parse(Console.ReadLine());
quantity++;
size=size+w*h;
}
Console.WriteLine("The quantity is "+quantity+", the price is "+30*quantity);