MIT Professional Education Discrete Math Programing Java Worksheet
Description
Unformatted Attachment Preview
import java.util.Scanner;
import java.lang.Math;
// Direct Proof
// if m and n are both perfect squares,
// then nm is also a perfect square.
// define public class and declare variables:
class Lab3 {
public static void main(String[] args) {
int n;
int m;
double sqrRootm;
double sqrRootn;
double sqrRootmn;
// Request user input of m and n:
Scanner Sc = new Scanner(System.in);
System.out.print(“Enter m: “);
m = Sc.nextInt();
System.out.print(“Enter n: “);
n = Sc.nextInt();
// calculate square roots of m, n and m*n
// print the square roots
// check if variables are perfect squares (m is given):
if (m % sqrRootm != 0) {
System.out.println(m + ” is not a perfect square.”);
} else {
System.out.println(m + ” is a perfect square.”);
}
// do the same for all variables
}
}
}import java.util.Scanner;
import java.lang.Math;
// Direct Proof
// if m and n are both perfect squares,
// then nm is also a perfect square.
// define public class and declare variables:
class Lab3 {
public static void main(String[] args) {
int n;
int m;
double sqrRootm;
double sqrRootn;
double sqrRootmn;
// Request user input of m and n:
Scanner Sc = new Scanner(System.in);
System.out.print(“Enter m: “);
m = Sc.nextInt();
System.out.print(“Enter n: “);
n = Sc.nextInt();
// calculate square roots of m, n and m*n
// print the square roots
// check if variables are perfect squares (m is given):
if (m % sqrRootm != 0) {
System.out.println(m + ” is not a perfect square.”);
} else {
System.out.println(m + ” is a perfect square.”);
}
// do the same for all variables
}
}
}
Purchase answer to see full
attachment
import java.lang.Math;
// Direct Proof
// if m and n are both perfect squares,
// then nm is also a perfect square.
// define public class and declare variables:
class Lab3 {
public static void main(String[] args) {
int n;
int m;
double sqrRootm;
double sqrRootn;
double sqrRootmn;
// Request user input of m and n:
Scanner Sc = new Scanner(System.in);
System.out.print(“Enter m: “);
m = Sc.nextInt();
System.out.print(“Enter n: “);
n = Sc.nextInt();
// calculate square roots of m, n and m*n
// print the square roots
// check if variables are perfect squares (m is given):
if (m % sqrRootm != 0) {
System.out.println(m + ” is not a perfect square.”);
} else {
System.out.println(m + ” is a perfect square.”);
}
// do the same for all variables
}
}
}import java.util.Scanner;
import java.lang.Math;
// Direct Proof
// if m and n are both perfect squares,
// then nm is also a perfect square.
// define public class and declare variables:
class Lab3 {
public static void main(String[] args) {
int n;
int m;
double sqrRootm;
double sqrRootn;
double sqrRootmn;
// Request user input of m and n:
Scanner Sc = new Scanner(System.in);
System.out.print(“Enter m: “);
m = Sc.nextInt();
System.out.print(“Enter n: “);
n = Sc.nextInt();
// calculate square roots of m, n and m*n
// print the square roots
// check if variables are perfect squares (m is given):
if (m % sqrRootm != 0) {
System.out.println(m + ” is not a perfect square.”);
} else {
System.out.println(m + ” is a perfect square.”);
}
// do the same for all variables
}
}
}
Purchase answer to see full
attachment
Explanation & Answer:
1 Script
User generated content is uploaded by users for the purposes of learning and should be used following our honor code & terms of service.
Have a similar assignment? "Place an order for your assignment and have exceptional work written by our team of experts, guaranteeing you A results."