import java.util.Scanner;
class PerfectSquare
{
public static void main(String args[])
{
Scanner input = new
Scanner(System.in);
//prompt user to enter a
number
System.out.println("\nEnter a
number: ");
int n = input.nextInt();
//findout squar root of the given
number
int temp=(int)Math.sqrt(n);
//if temp^2 is equal to user
entered number
//perfect square
if(Math.pow(temp,2)==n)
System.out.println("\nPerfect Square\n");
//else not perfect number
else
System.out.println("\nNot perfect square\n");
}
}
//Random number by using Random class
import java.util.Scanner;
import java.util.Random;
public class RandomNumber
{
public static void main(String args[])
{
Scanner input =
new Scanner(System.in);
Random rand =
new Random();
//prompt user to
enter a min number
System.out.println("\nEnter a min number: ");
int min =
input.nextInt();
//prompt user to
enter a max number
System.out.println("\nEnter a max number: ");
int max =
input.nextInt();
//generating
random number in given range
int random =
rand.nextInt(max)+min;
//displaying to
user
System.out.println("Random number "+random);
}
}
IN JAVA 1. Create a program that prompts the user for an integer and then displays...
C++ Write a program that prompts the user to enter integers or a sentinel to stop. The program prints the highest and lowest numbers entered, the sum and the average. DO NOT USE ARRAYS, only variables and loops. Write a program the prompts the user to input a positive integer. Keep asking the user until a positive integer is entered. Once a positive integer is entered, print a message if the integer is prime or not. (NOTE: A number is...
C++ Problem #1 Write a program that prompts user to enter an integer up to 1000 and displays back a message about the number of digits in this number and if number is odd or even. For example, if user enters 93 message back should be "93 has 2 digits and is odd".
write a java program that displays the following: Write a Java program that prompts the user to enter an integer and determines whether 1. it is divisible by 5 and 6, whether on 2. it is divisible by 5 or 6, 3. it is divisible by 5 or 6, but not both. Here is a sample run of this program: Sample run: Enter an integer: 10 Is 10 divisible by 5 and 6? false Is 10 divisible by 5 or...
In Java - Write a program that prompts the user to enter two integers and displays their sum. If the input is incorrect, prompt the user again. This means that you will have a try-catch inside a loop.
Write a program that (in the main program) prompts the user for the (integer) model number of their car. The main function should then call the function check defective which should • take in the model number of the car • check if the model number is 119, 179, 221, 780, or anything between 189 and 195, inclusive, which indicates the car is defective • print a message indicating whether or not the car is defective Note: this is should...
c++ please (1) Write a program that prompts the user to enter an integer value N which will rpresent the parameter to be sent to a function. Use the format below. Then write a function named CubicRoot The function will receive the parameter N and return'its cubic value. In the main program print the message: (30 Points) Enter an integer N: [. ..1 The cubic root of I.. ] is 2 update the code om part and write another function...
In Java Programming: Create a flow chart for a program that prompts for an integer N (number of students) and M (number of test scores for each students), and allows the user to N*M real numbers. The program then calculates the average for each student and class average. (1) Prompt the user to input N students and M test scores, then display the inputs. Enter number of students: You entered: 2 Enter number of test scores: You entered: 3 Enter...
Task 1 : Write a Java program that prompts for and reads 10 integers from the user into an integer array of size 10, it then: - calculates the sum and average of positive numbers of the array and displays them. [Note: consider 0 as positive] Note: The program must display the message: "There are no positive values" if the array does not contain any positive value.
Write a JAVA program that prompts the user for student grades and displays the highest and lowest grades in the class. The user should enter a character to stop providing values. Starter code: import java.util.Scanner; public class MaxMinGrades{ public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter as many student grades as you like. Enter a character to stop."); double grade = input.nextDouble(); double minGrade = Double.MAX_VALUE; double maxGrade = Double.MIN_VALUE; while (Character.isDigit(grade)) { if (grade == 0)...
Program#3(17 points): write a java program (SunDigits) as follows The main method prompts the user to enter an integer number. The method then calls Method Sum (defined blew) to add the digits and return their total. The main method then prints the digits total with proper label as shown below Method Sum )is of type integer and takes an integer value. The method recursively adds up the digits and returns their total. Document your code and use proper prompts for...