B. training is the correct answer
Answer:
// program in Python to check perfect number
#function to find number is perfect or not
def is_Perfect_Number(n):
#total variable
tot = 1
i = 2
#sum of all divisor of number
while i*i<=n:
if n%i==0:
tot = tot + i + n/i
if tot == n and n != 1:
return 1
i = i+1
return 0
#read until user enter a perfect number
while True:
#read integer
num = int(input("Input an integer: "))
#call the function
if(is_Perfect_Number(num)):
print(num,"is perfect number")
#if perfect number break
break
else:
print(num,"is not a perfect number")
#ask again
print("try again.")
Explanation:
Read number from user and then call the function is_Perfect_Number() with parameter "num".This will find the sum of all divisor of number.If sum is equal to number then it will return 1 else return 0.If the number is not perfect then it will again ask to enter a number until user enter a perfect number.
Output:
Input an integer: 24
24 is not a perfect number
try again.
Input an integer: 28
28 is perfect number
They both need electricity. Both used in the kitchen.
whats the question?????????????????????
Answer:
import java.util.Scanner;
public class Solution {
public static void main(String args[]) {
Scanner scan = new Scanner(System.in);
System.out.println("Enter your value");
int value = scan.nextInt();
greaterThanFive(value);
}
public static void greaterThanFive(int userInput){
System.out.println(userInput > 5);
}
}
Explanation:
The first line import the Scanner which is use to enable to accept user input.
The class is defined as Solution in the next line. The main method is declared in the next line which signify the beginning of the program.
Then, a scanner object is declared called scan in the next line. Then a prompt is display to the user to input a value. The user input is stored in the variable value. The value is then passed to the method greaterThanFive.
The method greaterThanFive is declared and have just one parameter, the userInput. Inside the method, we output if the userInput is greater than 5 using the logical operator (>).