do this... It's Java Programming
Attachments:
Answers
Answered by
4
Required Answer:-
Question:
- Write a Java program to print the squares of all the numbers from x to y.
Solution:
Here comes the program.
import java.util.*;
public class Squares {
public static void main(String[] args) {
int x, y;
Scanner sc=new Scanner(System.in);
System.out.print("Enter x - ");
x=sc.nextInt();
System.out.print("Enter y - ");
y=sc.nextInt();
System.out.println("Squares of numbers in range "+x+" to "+y+" are..");
while(x<=y) {
System.out.print(x*x+" ");
x++;
}
sc.close();
}
}
Algorithm:
- START
- Accept the range from the user, say x - y.
- Display the squares of numbers in the range x - y.
- STOP.
See the attachment for output.
Attachments:
Answered by
3
Yeah Jessica
what m I
A PoTAEto
I m also your chiingu T_T
Similar questions
Social Sciences,
2 months ago
English,
5 months ago
Math,
5 months ago
Biology,
11 months ago
Hindi,
11 months ago