Вы находитесь на странице: 1из 4

/*

* To change this license header, choose License Headers in Project Properties.


* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package switch1;

/**
*
* @author ryan
*/
public class Switch1 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int month = 3;
String monthString;
switch (month){
case 1:monthString="January";break;
case 2:monthString="February"; break;
case 3:monthString="February"; break;
case 4:monthString="February"; break;
case 5:monthString="February"; break;
case 6:monthString="February"; break;

default:monthString="Invalid month";

}
System.out.println(monthString);

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package pkg1;

import java.util.Scanner;

/**
*
* @author ryan
*/
public class Main {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
String month;
int day;
Scanner input = new Scanner (System.in);
System.out.print ("Enter a month:");
month = input.next();
System.out.println ("Days");
day = input.nextInt();
System.out.print("\n");
if (null != month)
switch (month) {
case "January":
System.out.printf ("The month you choose is %s:",month);
System.out.print("31");
break;
case "February":
System.out.printf ("The month you choose is %s:",month);
System.out.print("29");
break;
case "March":
System.out.printf ("The month you choose is %s:",month);
System.out.print("31");
break;
default:
break;
}
}

// TODO code application logic here


}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package ff;

import java.util.Scanner;
/**
*
* @author ryan
*/
public class Ff {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner in=new Scanner(System.in);
System.out.println("1st integer");
int firstInt = in.nextInt();
System.out.println("2nd integer");
int secondInt = in.nextInt();
int sum=firstInt+secondInt;
System.out.printf("Sum of two integers:%d%n,",sum);
double aver=(firstInt+secondInt)/2;
System.out.printf("Average of two integers:%2f%n,",aver);
// TODO code application logic here
} // TODO code application logic here
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javaapplication4;

import java.util.Scanner;

/**
*
* @author ryan
*/
public class JavaApplication4 {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {
Scanner input = new Scanner (System.in);
System.out.println("Enter your number");
int number = input.nextInt();
System.out.println("Plz enter a number:"+number);
int number2 = input.nextInt();
System.out.println("Plz enter a number:"+number2);
int sum=number+number2;
System.out.printf("Sum of two:%d%n,",sum);
int diff=number-number2;
System.out.printf("Diff of two:%d%n,",diff);
int multi=number*number2;
System.out.printf("Multi of two:%d%n,",multi);
int div=number/number2;
System.out.printf("Div of twi:%d%n,",div);
// TODO code application logic here
}

/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package rey;

import java.util.Random;

/**
*
* @author ryan
*/
public class Rey {

/**
* @param args the command line arguments
*/
public static void main(String[] args) {

Random dice;
dice = new Random();
int number;
for (int counter=1; counter<=10; counter++){
number= dice.nextInt(6);
System.out.println (number+" ");

}
}

Вам также может понравиться