Question

In: Computer Science

Write a Java program where you will set the datatype and variables to find the value...

Write a Java program where you will set the datatype and variables to find the value of following expression.

The Values of the variables to be used are given below

a) 101 + 0) / 3

b) 3.0e-6 * 10000000.1

c) true && true

d) false && true

e) (false && false) || (true && true)

f) (false || false) && (true && true)

Solutions

Expert Solution

JAVA Program:

import java.io.*;

public class ExpressionEvaluator {
   public static void main(String[] args) {
       int exp1 = (101 + 0) / 3;
       double exp2 = 3.0e-6 * 10000000.1;
       boolean exp3 = true && true;
       boolean exp4 = false && true;
       boolean exp5 = (false && false) || (true && true);
       boolean exp6 = (false || false) && (true && true);
      
       System.out.println("(101 + 0) / 3) ---- " + exp1);
       System.out.println("(3.0e-6 * 10000000.1) ---- " + exp2);
       System.out.println("(true && true) ---- " + exp3);
       System.out.println("(false && true) ---- " + exp4);
       System.out.println("((false && false) || (true && true)) ---- " + exp5);
       System.out.println("(false || false) && (true && true) ---- " + exp6);
   }
}

Output:


Related Solutions

you are to write a program in Java, that reads in a set of descriptions of...
you are to write a program in Java, that reads in a set of descriptions of various geometric shapes, calculates the areas and circumferences of the shapes, and then prints out the list of shapes and their areas in sorted order from smallest to largest area. There are four possible shapes: Circle, Square, Rectangle, and Triangle. The last is always an equilateral triangle. The program should read from standard input and write to standard output. The program should read until...
JAVA PROGRAM 1. Write a program to find the factorial value of any non-negative number entered...
JAVA PROGRAM 1. Write a program to find the factorial value of any non-negative number entered through the keyboard.(method) (Factorial of n: n! = 1*2*3*…*n, 0! = 1.) 2. Write a program that prompts the user to input a positive integer. It should then output a message indicating whether the number is a prime number. (method) Please post a screenshot of the codes. Thanks!
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements,...
Write the program in Java. Demonstrate that you know how to define variables, create conditional statements, write a loop, use arrays, obtain input from the user, display output, test and create a JavaDoc. Create project PaystubTest2 that is a Paystub calculator with program Paystub##.java (where ## is your initials) based on user input. (10 points) You must use the ReadStringFromUser and ReadFloatFromUser methods in the program to obtain user input. (20 points) This program will calculate the Gross Earnings, FICA...
Write a program in JAVA to create the move set of a Pokémon, and save that...
Write a program in JAVA to create the move set of a Pokémon, and save that move set to a file. This program should do the following: Ask for the pokemon’s name. Ask for the name, min damage, and max damage of 4 different moves. Write the move set data into a file with the pokemon’s name as the filename. The format of the output file is up to you, but keep it as simple as possible
Create a JAVA program to find the mean and standards deviation of a large set of...
Create a JAVA program to find the mean and standards deviation of a large set of data by breaking it down into smaller sets and use threads to process each smaller data set. The simulation will use only 3 threads, and each data set will be at most 100 integers. Create two classes, namely HadoopSim class for the thread tasks and HadoopDriver class for the main routine. (Then the main routine must gather up the results of each thread and...
Define what an array index value is in JAVA. Then, write a JAVA program that passes...
Define what an array index value is in JAVA. Then, write a JAVA program that passes an array to a method and finds the average value or mean value (add up the numbers in the array and divide by the number of values) of the array and prints it out.
Write a program in Java that reads in a set of positive integers and outputs how...
Write a program in Java that reads in a set of positive integers and outputs how many times a particular number appears in the list. You may assume that the data set has at most 100 numbers and -999 marks the end of the input data. The numbers must be output in increasing order. For example, for the data 15 40 28 62 95 15 28 13 62 65 48 95 65 62 65 95 95 -999 The output is...
Write a Java program to read a set of integers from a file, dataX, and a...
Write a Java program to read a set of integers from a file, dataX, and a set of ranges from a second file, rangeX, and, for each range [a, b] in rangeX, report the SUM of all the integers in dataX which are in the range [a, b]. As the integers are read from file dataX, insert them in a binary search tree. After all the integers have been inserted into the binary search tree, read the ranges from file...
Java Write a program to record the GPAs of a class and find the percentage of...
Java Write a program to record the GPAs of a class and find the percentage of students in each GPA. The program first allows the user to enter the number of students enrolled in the class, and then to enter the GPA of all students one by one. For each student, the input must be between 1 and 4 inclusively. Otherwise, the software displays a message as “Invalid number!” and asks for a new GPA for the same student Enter...
3) Create a Java program that uses NO methods, but use scanner: Write a program where...
3) Create a Java program that uses NO methods, but use scanner: Write a program where you will enter the flying distance from one continent to another, you will take the plane in one country, then you will enter miles per gallon and price of gallon and in the end it will calculate how much gas was spend for that distance in miles. Steps: 1) Prompt user to enter the name of country that you are 2) Declare variable to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT