Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions JAVA/Input.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
import java.util.*;
class input
{
static void scanner_input()
static void scanner_input ()
{
Scanner sc = new Scanner(System.in);

System.out.println("Enter a string(using Scanner)");
String s = sc.nextLine();
System.out.println("Entered String is : "+s);
Expand All @@ -17,7 +18,7 @@ static void scanner_input()
System.out.println("Entered number is : "+n);
}

static void buffered_input() throws IOException
static void buffered_input () throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

Expand All @@ -29,15 +30,15 @@ static void buffered_input() throws IOException
System.out.println("Entered number is : "+n);
}

static void right_shift()
static void right_shift ()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter a number");
int num = sc.nextInt();
System.out.println("After shifting :"+(num>>3));
}

public static void main(String[] args)
public static void main (String[] args)
{
String s = args[0];
double d = Double.parseDouble(args[1]);
Expand All @@ -51,7 +52,7 @@ public static void main(String[] args)
{
buffered_input();
}
catch(Exception e)
catch (Exception e)
{
System.out.println(e);
}
Expand Down
34 changes: 23 additions & 11 deletions JAVA/addcomplex.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
class number
{
int real,im;
number()
{ real=0; im=0; }
number(int r,int i)

number ()
{
real=0; im=0;
}

number (int r,int i)
{
real=r; im=i;
}
void display()

void display ()
{
System.out.println(" Number is "+real+"+"+im+"i");
}
number add(number num)

number add (number num)
{
number answer = new number();
answer.real =real+num.real;
Expand All @@ -26,21 +32,27 @@ number add(number num)

class addcomplex
{
public static void main(String[] args)
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);

System.out.println("Enter real part of 1st number ");
int realnum=sc.nextInt();
int realnum = sc.nextInt();

System.out.println("Enter imaginary part of 1st number ");
int imaginary=sc.nextInt();
int imaginary = sc.nextInt();
number c1 = new number(realnum,imaginary);

System.out.println("Enter real part of 2nd number ");
int realnum1=sc.nextInt();
int realnum1 = sc.nextInt();

System.out.println("Enter imaginary part of 2nd number ");
int imaginary1=sc.nextInt();
number c2 = new number(realnum1,imaginary1);
int imaginary1 = sc.nextInt();

number c2 = new number(realnum1, imaginary1);
number c3 = new number();
c3 = c1.add(c2);

c3.display();
}
}
6 changes: 3 additions & 3 deletions JAVA/grade.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
import java.util.*;
class grade
{
public static void main(String[] args)
public static void main (String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter marks of student");
int marks = sc.nextInt();

if(marks > 100)
if (marks > 100)
marks = -1;
else
marks = marks/10;

switch(marks)
switch (marks)
{
case 10:
case 9: System.out.println("Grade : A");
Expand Down