day02_ variable data types and operators

public class jh_07_ concept expression {
 public static void main (String [] args) {
 
  / *
   * are composed of a sequence of symbols and operands.
   10 *
   * A;
   * A = 10;
   * A + B * 10
   * the content can be an expression assigned to a variable.
   SUM = A + B *
   * 10 = X
   * + X * Y = 2. 1
   * /
  
   }
}

 


Assignment exchange between the two values {public class jh_o8_ variable
 public static void main (String [] Arge) {
  // swap values of the variables.
  
  / *
   * Interchangeable left and right hands.
   * Ideas:
   * 1: put one hand (left) put something on the table;
   * 2: put your other hand (right) thing to the left.
   * 3: to put things on the table to the right hand;
   * ------
   * left hand -------- Table
   * -------- right hand;
   * the table ------ - right hand;
   * /
  
  int a = 10; // left;
  int = B. 8; // the right;
  
  // declare a variable showing a table;
  int TEMP;
  // ------- left the table;
// tables left =
  TEMP = A;
// ------- left hand
  A = B;
// ------- Table right;
  B = TEMP;
  
  System.out.println (A);
  the System.out. the println (B);
  
  
 }
 
  
}


public class jh_09_ arithmetic operators {
 public static void main (String [] args) {
  / *
   * plus
   * minus
   * Multiplication
   * except
   * modulo (or called modulo)
   * /
  
  
  int = A. 7;
  int. 4 = B;
  SUM = A + B int;
  System.out.println (1000);
  int Money = 1000;
  System.out.println (Money);
    
  System.out.println (SUM);
  
  
  System.out.println (A + B); plus //
  System.out.println (a - b); // Save
  System.out.println (a * b); // multiplication
  // integer other integer or integers.
  System.out.println (a / b); // other
  
  
  //% Remainder - to actually divide the left and right, return the remainder.
  System.out.println (A & B);
  
  
// input from the console 3 course grade students Hao
  int stb = 99, java = 88 , sql = 76;
  
  int cha = java - sql;
  double avq = (stb + java + sql)/3.0;
  
  
  System.out.println("----------");
  System.out.println("STB\tJAVA\tSQL");
  System.out.println(stb + "\t" + java+"\t"+sql);
  System.out.println("----------");
  System.out.println("成绩差:"+cha);
  System.out.println("平均分:"+avg);
 }
 
 
 
 
}


public class jh_10_ compound assignment operators {
 public static void main (String [] args) {
  // compound assignment operators + = - * /%
  
  int. 5 A =, B = 2;
  System.out.println (A);
  
  A + = b; // do the left and right of the adder, and then assigned to the left
  // A = A + B
  
  the System.out .println (A);
  
  A - = B;
  A * = B;
  A / = B;
  A =% B;
  / *
   * = + later for accumulating sum
   *. 1 + 2 + +. 5. 4. 3 +
   * (. 1 + 2) +. 3
   * SUM +. 3
   * SUM = SUM +. 3;
   * SUM + =. 3;
   * ( (. 1 + 2) +. 3). 4 +
   * + SUM. 4;
   * SUM = SUM +. 4;
   * SUM + =. 4;
   * 
   * = I. 1
   * SUM = 0;
   * 
   * Sum + = i;
   Print * (sum)
   * i = 2;
   * Sum + = i;
   * - sum = 3
   * i = 3;
   * Sum + = i;
   * 
   * /
  
  
 }
 
}
 

public class jh_11_ and Subtraction operator {
 public static void main (String [] args) {
  
  / * Save Save the Comparative jerk
   * +: increase since. Data be added to 1
   * -: decrement. Save the original data 1
   * /
  
  / * using involved in computing separate Comparative
   * 1: alone: on the back and front of the operands the same effect. (Common)
   * 2: Participation operations using:
          * on the front of the operands, the first increment-decrement and then participate in the operations.
             * On the back of the operands, the first operation participate, then increment decrement.
   * /
  
  
  Int = A. 5;
  System.out.println (A);. 5 //
  int B = 2;
  System.out.println (B); 2 //
  System.out.println ( "======= == ");
  
  
  //System.out.println (A ++);
  // add A ++ itself. 1
  //System.out.println (B -);
  // B - Save itself. 1
  
  int count = 0;
  
  //   count ++;
     //System.out.println(count);
  
  
  //   count --;
  //System.out.println(count);
  
  
 }
}
 

public class jh_12_a difference between a jerk and the jerk {
 public static void main (String [] args) {
  int a =. 5;
  int = B. 5;
  
  int X = a * 2 ++;
  System.out.println (X) ;
  int Y = B * 2;
  System.out.println (Y);
  / *
   * A ++ do first operation itself and then adding 1
   * ++ A is to add more 1, then do calculation
   * /
  the System .out.println (A);
  System.out.println (B);
  
  
  
  //System.out.println (A ++); //. 5
  // ++ A first output is then coupled. 1
  //System.out. println (++ b);
  // b ++ first and then add 1 to their own output.
  
  
A ++ //;
// b ++;
//  
// No matter what is on their own plus 1
// System.out.println (A);
// System.out.println (b);
  
  
 }
}
 

import java.util.Scanner;
public class jh_13_ keyboard input {
 / *
  * 1: block: {----} braces content
  * 2: Function: function to complete a specific block of code
  * the nextInt ();
  *. 3: use the function calls . The object name in the function name ();
  * 4: Scanner keyboard input object.
  Scanner Scanner new new SC = * (the System.in);
  . * Object name function name ();
  * sc.nextInt ();
  * A = sc.nextInt int ();
  *
  * /
 
 public static void main (String [] args ) {
  // create a keyboard input objects
  Scanner Scanner new new SC = (the System.in);
  System.out.println ( "enter a value of:");
  // in a console input integer,
  // this input integer assigned to a.
  B = 10 int;
  int sc.nextInt A = ();
  System.out.println (A);
  
 }
}
 

public class jh_14_ automatic type conversions example {
 / * score for the first time a student 81.29,
  * a second multi attained during the first 2 minutes,
  * find second fraction?
  * /
 Public static void main (String [] args) {
  // first fraction 81.29
  Double firstScore = 81.29;
  // second fraction than the first two points a plurality
  Double secondScore;
  secondScore firstScore = + 2;
  
  / *
   * 2 2.0 ----
   * 2.0 ----- 2
   * /
  // output:
  System.out.println ( "second fraction is:" + secondScore);
     Double a = 2;
     System.out.println (A);
     // automatic conversion implicit conversion
     // mandatory ---- ---- ----
    
 }
}
public class jh_15_ cast {
 public static void main (String [] args) {
  // Apple notebook market share last year was 20,
  int lastyear = 20;
  
  // this year's growing market share is 9.8
  Double thisYear = + lastyear 9.8;
  // can be converted
 // int thisYear = (int) thisYear + 9.8;
  
 // (int) (lastyear + 9.8)
 // lastyear + 9.8
 // class. Types of. 
  thisYear lastyear + = int (int) 9.8;
  
  
 }
 
}
 
 
 
 
 
 
 
 

 
 
public class jh_18_ how to use Boolean type {
  / * input from the console classmate Zhang achievements,
   * and John Doe score (80 points) compared
   * Output "Joe Smith John Doe score higher than the score it?"
   * the determination result
   * /
 public static void main (String [] args) {
  // new new Scanner Scanner SC = (the System.in);
// Zhang score input from the console
  int a = 10;
  System.out.println (a );
  System.out.println ( "Please enter Joe Smith's achievement:");
  int zhangScore = 80;
  
// John Doe and scores (80) points relatively
// John Doe score (80)
  int liScore = 80;
  
// John Doe John's score is higher than the scores?
  zhangScore the Result = boolean> liScore;
  
  // output
  System.out.println (+ result "high?");
 }
}
 

 

 

public class jh_20_ School of small ticket printing operation _ {
  / *
   * the amount of consumption of each product sum * Discount
   * /
  public static void main (String [] args) {
  // Product Name
      String tx = "T Xu";
      String WQX = "tennis shoes";
      String WQP = "racket";
  
     // monovalent
      int txPrice = 245;
      int wqxPrice = 570;
      int = 320. wqpPrice;
     
     // number
      int txNum = 2;
      int = wqxNum. 1;
      int. 1 = wqpNum ;
     
    // calculate the amount of each item;
      int * txNum txMoney = txPrice;
      int * wqxNum wqxMoney = wqxPrice;
      int * wqpNum wqpMoney = wqpPrice;
  
    // output theme upper part.
  System.out .println ( "************* consumption single *************");
  System.out .println ( "purchase items \ t Price \ t the number \ t amount ");
  System.out .println (tx +" \ t ¥ "+ txPrice +" \ t "+ txNum +" \ t ¥ "+ txMoney);
  System.out .println (WQX +" \ T ¥ "+ wqxPrice +" \ T "+ wqxNum +" \ T ¥ "+ wqxMoney);
  the System.out .println (WQP +" \ T ¥ "+ wqpPrice +" \ T "+ wqpNum +" \ T ¥ "+ wqpMoney);
 
    // given a discount
  double discount = 0.8; // 8 off
  
    // calculate the total amount of consumption allmoney ----:
  Double allmoney = (+ wqpMoney wqxMoney txMoney +) * discount;
  
  // given actual payment amount 1500
  int Money = 1500;
  
  // calculation give change. leftMoney;
  Double leftMoney = Money - allmoney;
  
  // calculate points. 100 3 points.

  

  
  System.out.println ( "discount \ t" + (int) ( discount * 10) + " discount");
  System.out.println ( "total amount of consumption: ¥" + allmoney);
  System.out.println ( " give change: \ t "+ leftMoney);
  System.out.println (" points: \ t "+ integral);
  
  / *
   * 1: variable name given nine. Store content.
   * 2: Output screenshot upper part
   * 3: do arithmetic.
   * 4: The output of the operational result.
   * /
  
  
  
  
  }
}
 

 
 
 

 

Guess you like

Origin www.cnblogs.com/sirendingzhi/p/11121084.html