בלאט 1 פון 1

ווער וויל מיך אויסלערנען JAVA ?

פארעפענטליכט: דינסטאג פבואר 21, 2012 2:58 pm
דורך בלעקבערי פען
איך פרוביר צומאכעו א קאלקולעטער

נאכען אסאך ליינען האב איך קודם דאס אהער געשטעלט

דאס איז די מעין מעטאד
קאוד:
import static java.lang.System.out;

public class ProfessionalCalculator {

   public static void main(String[] args) {
      MathCalculator first = new MathCalculator();
      
      out.println("welcome to my calculator");
      
      first.promptForFirstInput();
      first.firstInput = first.input.nextDouble();
      
      
      first.promptForSecondInput();
      first.method = first.input.nextInt();
      
      first.myWhile();
      
      first.promptForThirthInput();
      first.secondInput = first.input.nextDouble();
   
      first.myResults();
      
   }

}


און דאס ענהאלט די קלאס

קאוד:
import java.util.Scanner;

public class MathCalculator {
   
   Scanner input = new Scanner (System.in);
   
   double firstInput ;
   int method ;
   double secondInput;
   double results;

   
   void promptForFirstInput() {
      System.out.println("enter the first amount  :  ");
   }
   
   void promptForSecondInput() {
      System.out.println("enter 1=+ 2=- 3=* 4=/ :  ");
   }
   
   void promptForThirthInput() {
      System.out.println("enter the second amount :  ");
         }

   
   
   void myWhile()
   {
      while  (method >4)
   {
      System.out.println("pleas enter a valid number");
      promptForSecondInput();   
      method = input.nextInt();
   }
   }

   
   
   void myResults() {
      
   
   switch (method) {
   case 1:
      System.out.println(firstInput + secondInput);
      break;
   case 2:
      System.out.println(firstInput - secondInput);
      break;
   case 3:
      System.out.println(firstInput * secondInput);
      break;
   case 4 :
      System.out.println(firstInput / secondInput);
      break;
   

   default:
      System.out.println("i dont know what u entered");
      break;
   }
   }
   }
   


פארעפענטליכט: דינסטאג פבואר 21, 2012 3:02 pm
דורך בלעקבערי פען
קען מיך איינער אפשר ארויס העלפען וויאזוי צו רעטארנען מיין חשבון צו מיין וואר רעזאלט ??

פארעפענטליכט: דינסטאג פבואר 21, 2012 8:19 pm
דורך בלעקבערי פען
איך האב עס אליינס געמאכט אזוי
קאוד:
import static java.lang.System.out;

public class ProfessionalCalculator {

   public static void main(String[] args) {
      MathCalculator first = new MathCalculator();
      MathCalculator second = new MathCalculator();
      out.println("welcome to my calculator");
      
      first.promptForFirstInput();
      first.firstInput = first.input.nextDouble();
      
      
      first.promptForSecondInput();
      first.method = first.input.nextInt();
      
      first.myWhile();
      
      first.promptForThirthInput();
      first.secondInput = first.input.nextDouble();
   
      first.mySwitch();
      
      out.print(first.firstresult);
      
      
      
      
      
      out.println("");
      out.println("pleas enter another number");
      first.thirdInput = second.input.nextDouble();
      
      second.promptForSecondInput();
      first.method = second.input.nextInt();
      second.myWhile();
      
      
      first.mySwitch1();
      
      
      out.println("");
      out.println(first.secoundResult);
   }

}



קאוד:
import java.util.Scanner;

public class MathCalculator {
   
   Scanner input = new Scanner (System.in);
   
   double firstInput ;
   int method ;
   double secondInput;
   double thirdInput;
   double firstresult;
   double secoundResult;
   
   
   void promptForFirstInput() {
      System.out.println("enter the first amount  :  ");
   }
   
   void promptForSecondInput() {
      System.out.println("enter 1=+ 2=- 3=* 4=/ :  ");
   }
   
   void promptForThirthInput() {
      System.out.println("enter the second amount :  ");
         }

   
   
   void myWhile()
   {
      while  (method >4)
   {
      System.out.println("pleas enter a valid number");
      promptForSecondInput();   
      method = input.nextInt();
   }
   }

   
   
   void   mySwitch() {   
      switch (method) {
   case 1:
      firstresult = firstInput + secondInput;
      break;
   case 2:
      firstresult = firstInput - secondInput;
      break;
   case 3:
      firstresult = firstInput * secondInput;
      break;
   case 4 :
      firstresult = firstInput / secondInput;
      break;
   

   default:
      System.out.println("i dont know what u entered");
      break;
      }
   }
   
   
   void   mySwitch1() {   
         switch (method) {
      case 1:
         secoundResult = firstresult + thirdInput;
         break;
      case 2:
         secoundResult = firstresult - thirdInput;
         break;
      case 3:
         secoundResult = firstresult * thirdInput;
         break;
      case 4 :
         secoundResult = firstresult / thirdInput;
         break;
      

      default:
         System.out.println("i dont know what u entered");
         break;
         }
      }
   }
   

פארעפענטליכט: דינסטאג פבואר 21, 2012 8:32 pm
דורך היימישער איד
So is it working now? Or you still need some help?

פארעפענטליכט: דינסטאג פבואר 21, 2012 8:37 pm
דורך בלעקבערי פען
עס ארבעט שוין ב"ה

פארעפענטליכט: דינסטאג פבואר 21, 2012 8:50 pm
דורך היימישער איד
אה כ'האב הנאה צו הערן.

פארעפענטליכט: דאנערשטאג יוני 14, 2012 9:34 am
דורך מייקראסאפט
אין דשאווא איז דא א זאך וואס מען ניצט אסאך(?) ()System.out.println קען איינער געבען א הסבר וואס איז דאס? איך פארשטיי אז System איז א קלאס, (ווען מען דאנלאד דשאווא קימט מיט רעדי class וואס איז עוועילעבל צי ניצן), יעדע קלאס הייבט זיך אן מיט א קעפיטעל אות, יעצט וואס איז out א מעטעד? איינעם האב איך געזען שרייבן אז עס איז א וועריבל מאכט סענס???? איך מיין אז נישט.
אין וואס איז print? איך מיין אז עס קימט פין א קלאס PrintStream אבער וואס האט דאס מיט out????
עפעס הסבר?

פארעפענטליכט: דאנערשטאג יוני 14, 2012 7:48 pm
דורך תרגום יונתן
מען ניצט דאס צו שרייבן אינפארמאציע צום קאנסאל.

אין .NET איז דא ענליכס: System.Console.WriteLine (מען לאזט אויס System געווענליך, וויבאלד ס'איז א נעימספעיס און איז שוין אימפארטירט אין נייע פיילס).

println איז א מעטאד אויפ'ן קלאס PrintStream, וואס ליגט אינעם וועריעבל out, וואס ליגט אויפ'ן קלאס System.

פארעפענטליכט: דאנערשטאג מאי 09, 2013 9:09 pm
דורך בחורהזעצער
איז דא א וועג צו פרינטן א סטעקטרעס פון אן עקסעפשאן צו א וועריעבעל צו קענען לאמיר זאגן דאס שיקן אין א אימעיל? איך רעדט פון זשאווא MicroEdition וואס איז מערסטענס באגרעניצט און מען קען נישט מאכן די PrintWriter אבזשעקט וכדומה.