0% found this document useful (0 votes)
13 views7 pages

Kunal 1

Uploaded by

nishita6978
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)
13 views7 pages

Kunal 1

Uploaded by

nishita6978
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/ 7

package com.

kunal;

public class Basics {

public static void main(String[] args) {

// int a = 10;

// if (a == 10) {

// System.out.println("Hello World");

// }

// int count = 1;

// while(count != 5) {

// System.out.println(count);

// count++;

// }

// for loop

for(int count = 1; count != 5; count++) {

System.out.println(count);

package com.kunal;

import java.util.Scanner;
public class Inputs {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

// System.out.print("Please enter some input: ");

// int rollno = input.nextInt();

// System.out.println("Your roll number is " + rollno);

// String name = input.next();

// System.out.println(name);

// float marks = input.nextFloat();

// System.out.println(marks);

package com.kunal;

import java.util.Scanner;

public class Main {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

System.out.println(input.nextLine());

}
package com.kunal;

import java.util.Scanner;

public class Prime {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("Please enter a number: ");

int n = in.nextInt();

if(n <= 1) {

System.out.println("Neither prime nor composite");

return;

int c = 2;

while (c * c <= n) {

if (n % c == 0) {

System.out.println("Not Prime");

return;

c = c + 1;

// c++;

if (c * c > n) {

System.out.println("Prime");

}
package com.kunal;

public class Primitives {

public static void main(String[] args) {

int rollno = 64;

char letter = 'r';

float marks = 98.67f;

double largeDecimalNumbers = 4567654.4567;

long largeInteger = 34567834567876543L;

boolean check = false;

float c = 30.6f;

c++;

// c = (int)(c) + 1;

System.out.println(c);

package com.kunal;

import java.util.Scanner;

public class Sum {

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

float num1 = input.nextFloat();

float num2 = input.nextFloat();


float sum = num1 + num2;

System.out.println("Sum = " + sum);

package com.kunal;

import java.util.Scanner;

public class Temperature {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

System.out.print("Please enter temp in C: ");

float tempC = in.nextFloat();

float tempF = (tempC * 9/5) + 32;

System.out.println(tempF);

package com.kunal;

import java.util.Scanner;

public class TypeCasting {

public static void main(String[] args) {


Scanner input = new Scanner(System.in);

// float num = input.nextFloat();

// int num = input.nextInt();

// System.out.println(num);

// type casting

int num = (int)(67.56f);

// System.out.println(num);

// automatic type promotion in expressions

// int a = 257;

// byte b = (byte)(a); // 257 % 256 = 1

// byte a = 40;

// byte b = 50;

// byte c = 100;

// int d = a * b / c;

//

// System.out.println(d);

// byte b = 50;

// b = b * 2;

// int number = 'A';

// System.out.println("你好");

// System.out.println(3 * 6);

byte b = 42;

char c = 'a';

short s = 1024;
int i = 50000;

float f = 5.67f;

double d = 0.1234;

double result = (f * b) + (i / c) - (d * s);

// float + int - double = double

System.out.println((f * b) + " " + (i / c) + " " + (d * s));

System.out.println(result);

public class Demo {

public static void main(String[] args) {

System.out.println(args[1]);

public class Demo {

public static void main(String[] args) {

System.out.println(args[0]);

You might also like