0% found this document useful (0 votes)
6 views2 pages

Java Practical 1

Uploaded by

Sachin Angre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Java Practical 1

Uploaded by

Sachin Angre
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

2 Problem Statement

Write a Program whether number entered is armstrong or not.

Instructions

To find entered number is Armstrong or not.

Input: 371

output: Not Armstrong and Armstrong

import java.util.*;

public class Main

public static void main(String[] args)

Scanner myObj = new Scanner(System.in);

int number = myObj.nextInt();

int originalNumber, remainder, result = 0;

originalNumber = number;

while (originalNumber != 0)

remainder = originalNumber % 10;

result += Math.pow(remainder, 3);

originalNumber /= 10;

if(result == number)
System.out.println("Armstrong");

else

System.out.println("Not Armstrong");

You might also like