WAP to find the largest of n natural numbers - codewithshiva

Latest

Search Bar

Tuesday, August 4, 2020

WAP to find the largest of n natural numbers

Software Lab based on Java

WAP to find the largest of n natural numbers


package com.kapish;

import java.util.Scanner;
import java.lang.Math;
public class Main {

public static void main(String[] args) {
// WAP to find the largest of n natural numbers
Scanner sc= new Scanner(System.in); //System.in is a standard input stream.
System.out.print("Enter first number- ");
int a = sc.nextInt();

// now we will do (10^(a+1))-1

double t = 10;
double out = Math.pow(t,a)-1;
System.out.println("Biggest "+a+"Digit number is "+out);

}
}

No comments:

Post a Comment