Computer Science, asked by creatingmyselfrn, 10 months ago

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 TheArkhamKnight
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