[go: up one dir, main page]

0% found this document useful (0 votes)
27 views3 pages

Sample 2 Project

The document contains code for three Java projects demonstrating different programming concepts: 1) A Sample2 project that declares and prints various variable types. 2) An ArithmeticSample project that demonstrates arithmetic operators. 3) An AssignmentOperator project that demonstrates the assignment operator.

Uploaded by

dsdfsdfsd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
27 views3 pages

Sample 2 Project

The document contains code for three Java projects demonstrating different programming concepts: 1) A Sample2 project that declares and prints various variable types. 2) An ArithmeticSample project that demonstrates arithmetic operators. 3) An AssignmentOperator project that demonstrates the assignment operator.

Uploaded by

dsdfsdfsd
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

SAMPLE 2 PROJECT

package sample2;

public class Sample2 {

public static void main(String[] args) {


// This is my second sample
int age = 5;
int AGE = 25;
int Age = 45;
float b = 2.5F;
char a = 'F';
boolean flag1 = false;
boolean flag2 = true;
double d = 3.5;
String name = "hey";
System.out.println("Welcome to Sample 2");
System.out.println(name);
System.out.println(age);
System.out.println(AGE);
System.out.println(Age);
System.out.println(b);
System.out.println(a);
System.out.println(flag1);
System.out.println(flag2);
System.out.println(d);
}

}
ARITHMETIC SAMPLE PROJECT

package arithmeticsample;

public class ArithmeticSample {

public static void main(String[] args) {


int a = 12, b = 2, c;

// Addition operator
c = a + b;

System.out.println(" a + b = " + c );
System.out.println( a + " + " + b +" = " + ( a + b) );
// Substraction operator
System.out.println(" a - b = " + ( a - b) );
System.out.println( a + " - " + b +" = " + ( a - b) );
// Multiplication operator
System.out.println(" a * b = " + ( a * b) );
System.out.println( a + " * " + b +" = " + ( a * b) );
// Division operator
System.out.println(" a / b = " + ( a / b) );
System.out.println( a + " / " + b +" = " + ( a / b) );

}
ASSIGNMENT OPERATOR PROJECT

package assignmentoperator;

public class AssignmentOperator {

public static void main(String[] args) {

int a = 4;
int var;

var = a;
System.out.println("var using = : " +var);
// assign value using =+
var += a;
//var = var + a;
System.out.println("var using = : " +var);
var *= a;
// var = var * a;
System.out.println("var using = : " +var);
}

You might also like