wap in java to input n and create a loop to print the sum of (1)+(2^2)+ (3^3) +(n^n).
all inputs using scanner class.
Answers
Answered by
0
Answer:
import java.util.Scanner; // Import the Scanner class
class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in); // Create a Scanner object
System.out.println("Enter number: ");
float inputResult = Float.parseFloat(input.nextLine()); // Read user input
float finalResult = 1 + (2*2) + (3*3) + (inputResult*inputResult);
System.out.println(Float.toString(finalResult));
}
}
Explanation:
Similar questions
Math,
5 months ago
Social Sciences,
5 months ago
Physics,
5 months ago
Accountancy,
10 months ago
Science,
10 months ago
Sociology,
1 year ago
Economy,
1 year ago