Computer Science, asked by sonu9433, 11 months ago

write a program in Java input a number and print the cube of its unit's place digit

Answers

Answered by vkvinay6230
1

Answer:

This is a tutorial for square and cube of each digit in a number. Two programs are given below that explains it in detail. The program is not extendable. Go enjoy the program. Lets begin…

Program for square of each digit in number in java.

//import Scanner as we require it.

import java.util.Scanner;

// the name of our class its public

public class SquareDigit {

//void main

public static void main (String[] args)

{

//declare int

int no,m,s;

//Declare input as scanner

Scanner input = new Scanner(System.in);

//Take input

System.out.println("Enter Number :");

no = input.nextInt();

//add while loop

while(no>0)

{

m=no%10;

s = m*m;

System.out.println("Square of "+m+" is "+s);

no=no/10;

Similar questions