NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

// 01. Convert Meters to Kilometers

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int numbers = Integer.parseInt(scanner.nextLine());

System.out.printf(" %.2f", (double) numbers / 1000);
}
}

// 02. Pounds to Dollars

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double pounds = Double.parseDouble(scanner.nextLine());

double dollars = pounds * 1.36;

System.out.printf("%.3f", dollars);
}
}

// 03. Exact Sum of Real Numbers

import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());

BigDecimal sum = new BigDecimal(0);

for (int i = 0; i < n; i++) {
BigDecimal number = new BigDecimal(scanner.nextLine());
sum = sum.add(number);
}
System.out.println(sum);
}
}

// 04. City Info

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String city = scanner.nextLine();
String population = scanner.nextLine();
String area = scanner.nextLine();

System.out.printf("City of %s has population of %s and area %s square km.", city, population, area);
}
}

// 05. Concat Names

import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String firstName = scanner.nextLine();
String secondName = scanner.nextLine();
String symbol = scanner.nextLine();

System.out.printf("%s%s%s", firstName, symbol, secondName);
}
}

// 06 06. Chars to String
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Character n1 = scanner.nextLine().charAt(0);
Character n2 = scanner.nextLine().charAt(0);
Character n3 = scanner.nextLine().charAt(0);

System.out.printf("%c%c%c", n1, n2, n3);
}
}

// 07. Reversed Chars
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Character n1 = scanner.nextLine().charAt(0);
Character n2 = scanner.nextLine().charAt(0);
Character n3 = scanner.nextLine().charAt(0);

System.out.printf("%c %c %c", n3, n2, n1);

}
}

// 08. Lower or Upper
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
Character letter = scanner.nextLine().charAt(0);

if (letter == Character.toUpperCase(letter)) {
System.out.println("upper-case");
} else if (letter == Character.toLowerCase(letter)) {
System.out.println("lower-case");
}
}
}

// 09. Centuries to Minutes
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int centuries = Integer.parseInt(scanner.nextLine());

double years = centuries * 100;
double days = years * 365.2422;
double hours = days * 24;
double minutes = hours * 60;

System.out.printf("%d centuries = %.0f years = %.0f days " +
"= %.0f hours = %.0f minutes", centuries, years, days,
hours, minutes);
}
}

// 10. Special Numbers
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = Integer.parseInt(scanner.nextLine());

for (int i = 1; i <= n; i++) {
int sumOfDigits = 0;
int number = i;
while (number > 0) {
sumOfDigits += number % 10;
number /= 10;
}
if (sumOfDigits == 5 || sumOfDigits == 7 || sumOfDigits == 11) {
System.out.println(i + " -> True");
} else {
System.out.println(i + " -> False");
}
}
}
}

// 11. Refactor Volume of Pyramid
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
double dul, sh, V = 0;
System.out.print("Length: ");
dul = Double.parseDouble(scanner.nextLine());
System.out.print("Width: ");
sh = Double.parseDouble(scanner.nextLine());
System.out.print("Height: ");
V = Double.parseDouble(scanner.nextLine());
V = (dul * sh * V) / 3;
System.out.printf("Pyramid Volume: %.2f", V);

}
}

// 12. Refactor Special Numbers
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int num = Integer.parseInt(scan.nextLine());
for (int i = 1; i <= num; i++) {
int sum = 0;
int actualNum = i;
while (i > 0) {
sum += i % 10;
i = i / 10;
}
boolean trueFalse = (sum == 5) || (sum == 7) || (sum == 11);
String tF;
if (trueFalse) {
tF = "True";
} else {
tF = "False";
}
System.out.printf("%d -> %s%n", actualNum, tF);
i = actualNum;
}
}
}
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.