Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ValueOfExample {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- System.out.print("Enter first number: ");
- String firstValue = scanner.next();
- System.out.print("Enter second number: ");
- String secondValue = scanner.next();
- int indexFirstValue = firstValue.indexOf(",");
- if (indexFirstValue >= 0) {
- System.out.println("Comma in first number is located at position: " + firstValue.indexOf(","));
- }
- int indexSecondValue = secondValue.indexOf(",");
- if (indexSecondValue >= 0) {
- System.out.println("Comma in second number is located at position: " + secondValue.indexOf(","));
- }
- System.out.println(Double.valueOf(firstValue.replace(",", ".")) + " + " + Double.valueOf(secondValue.replace(",", ".")) + " = "
- + (Double.valueOf(firstValue.replace(",", ".")) + Double.valueOf(secondValue.replace(",", "."))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement