Computer Science, asked by Artybabe, 1 year ago

Pls give ans. I will mark it as brainliest, @aryamohan

Attachments:

Moo1: can we write a java program
Aryamohanan23: yes

Answers

Answered by Moo1
1
public class Digits{
public void calculate (int n){
int s= 0;
int d= 0;
while(n!=0){
d= n%10;
s= s+d*d;
n= n/10;
}
System.out.println("The sum of squares of digits is " + s);
}
}

###HOPE THIS HELPS
###MARK AS THE BRAINLIEST PLEASE

Aryamohanan23: it wont run..check your main
Moo1: But its running and i think its correct
Aryamohanan23: what is the syntax of main in java?
Aryamohanan23: do more search...
Moo1: You once run it and see
Aryamohanan23: Error: Main method not found in class Digits, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Command exited with non-zero status 1
Aryamohanan23: this is what i get as run your pgm
Moo1: is it now ok
Aryamohanan23: yea?
Aryamohanan23: Any leave it add the algorithm..thats actually needed
Similar questions