GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Basic-Java/ExBasicIO2.java at main · kavya-7777/Basic-Java

Expand file tree

/

ExBasicIO2.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
39 lines (33 loc) · 1.51 KB
/

ExBasicIO2.java

Copy path

File metadata and controls

39 lines (33 loc) · 1.51 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import java.util.Scanner;
public class ExBasicIO2{
public static void main(String[] args){
Scanner obj = new Scanner(System.in);
long x = obj.nextLong(); //absolute difference
long y = obj.nextLong();
long num = x-y;
System.out.println(Math.abs(num));
int n1 = obj.nextInt(); //print quotient with 16 decimal places and the remainder
int n2 = obj.nextInt();
double quotient = (double) n1/n2;
int remainder = n1%n2;
System.out.printf("The quotient when %d is divided by %d is %.16f\n",n1,n2,(double)n1/n2);
System.out.printf("The remainder when %d is divided by %d is %d",n1,n2,(n1%n2));
int a = obj.nextInt(); //Swap two numbers with temporary variable
int b = obj.nextInt();
int temp = a;
a = b;
b = temp;
System.out.print("num1="+a+"\n"+"num2="+b);
int num1 = obj.nextInt(); //Swap two numbers without temporary variable
int num2 = obj.nextInt();
num1=num1+num2;
num2=num1-num2;
num1=num1-num2;
System.out.println("num1="+num1);
System.out.println("num2="+num2);
int n = obj.nextInt(); //Accept a number which will be 1 or 2,
//char res = (n==1)?'2':'1'; //If it is 1, print 2. If it is 2, print 1.
int res = 3-n;
System.out.print(res);
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.