8 comments:

  1. import java.lang.Math;
    class Test{

    public static void main(String ar[])
    {

    int sum,rem,number,n1,loop=100;

    while(loop<1000)
    {

    number=loop;
    n1=number;
    rem=0;
    sum=0;
    while(number!=0)
    {
    rem=number%10;
    sum+=Math.pow(rem,3);
    number/=10;
    }
    if(n1==sum){System.out.printf("%d,",n1);}
    loop++;

    }
    }
    }

    ReplyDelete
  2. import java.util.Scanner;

    class Test
    {

    public static void main(String ar[])
    {
    int num=100,sum=0,temp,rem;

    while(num<1000)
    {
    temp=num;
    sum=0;
    while(temp>0)
    {
    rem=temp%10;
    sum=sum+(rem*rem*rem);
    temp=temp/10;
    }
    if (sum==num)
    System.out.println(num);
    num++;
    }
    }

    ReplyDelete
  3. //Armstrong
    import java.util.Scanner;
    class Armstrong
    {
    public static void main(String ar[])
    {
    int Number,Arm,OriNumber=0,Total=0,n;
    while(OriNumber<1000)
    {
    OriNumber++;
    Number=OriNumber;
    while(Number>0)
    {
    //Number=OriNumber;
    n=(Number%10);
    Total=Total+(n*n*n);
    Number=Number/10;
    }
    if(Total==OriNumber)
    {
    System.out.println(Total);
    System.out.println(" ");
    }
    Total=0;
    }
    }
    }

    ReplyDelete
  4. import java.util.Scanner;
    class Armstrong
    {
    public static void main(String Args[])
    {
    int i=100,num,rem,sum;
    while(i<1000)
    { sum=0;
    num=i;
    while(num>0)
    {
    rem=num%10;
    sum=sum+(rem*rem*rem);
    num=num/10;
    }

    if(sum==i)
    System.out.println(sum);
    i++;
    }
    }
    }

    ReplyDelete
  5. 16.
    import java.util.Scanner;

    public class JavaApplication6 {

    public static void main(String[] args) {


    Scanner obj=new Scanner(System.in);
    int num;
    num=obj.nextInt();
    int sum=0;
    int remainder;
    int temp;
    temp=num;
    while(num>0)
    {
    remainder=num%10;
    sum=sum+(remainder*remainder*remainder);
    num=num/10;
    }
    if(temp==sum)
    System.out.println("Yes it is a armstrong number");
    else
    System.out.println("no");
    }
    }

    ReplyDelete
  6. import java.util.Scanner;
    class armstrong
    {
    public static void main(String ar[])
    {
    Scanner scan = new Scanner(System.in);
    int num,remainder;
    System.out.println("enetr the number");
    num = scan.nextInt();
    int arm = 0;
    while(num>0)
    {
    remainder = num%10;
    arm=arm+remainder*remainder*remainder;
    num=num/10;
    }
    if(arm==num)
    System.out.println("it is the armstrong number");
    else
    System.out.println("it is not the armstrong number");
    }
    }

    ReplyDelete
  7. package com.example.myapplication;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.EditText;
    import android.widget.TextView;

    import javax.xml.transform.Result;

    public class Armstrong extends Activity {

    int num,temp,result=0,rem;
    EditText etArmstrong;
    TextView tvArmstrong;
    Button btArmstrong;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.armstrong);
    etArmstrong=findViewById(R.id.etArmstrong);
    tvArmstrong=findViewById(R.id.tvArmstrong);
    btArmstrong=findViewById(R.id.btarmstrong);

    btArmstrong.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
    num=Integer.parseInt(etArmstrong.getText().toString());
    //temp=num;

    while (num>0){
    rem=num%10;
    result=(rem*rem*rem)+ result;
    num=num/10;



    }
    tvArmstrong.setText("Result"+result);
    }
    });
    }
    }

    ReplyDelete
  8. import java.util.*;
    class Arm{
    public static void main(String ar[]){
    for(int n=100;n<1000;n++)
    {
    int sum=0,temp,rem=0,n1=0;
    temp=n;
    n1=n;


    while(temp>0)
    {
    rem=temp%10;
    sum=sum+(rem*rem*rem);
    temp=temp/10;
    }

    if (sum==n1)
    System.out.println(n1+"is armstrong");
    else
    System.out.println(n1+"is not armstrong");
    }

    }
    }


    ReplyDelete