Java Basic: Exercise-4 with Solution

Write a Java program to publish the result of the following operations.

Pictorial Presentation:

*

Sample Solution:

Java Code:

public course Exercise4 public revolution void main(String<> args) System.out.println(-5 + 8 * 6); System.out.println((55+9) % 9); System.out.println(20 + -3*5 / 8); System.out.println(5 + 15 / 3 * 2 - 8 % 3); Sample Output:

43 1 19 13Flowchart:

*

Sample Solution:

Java Code:

public class Main public revolution void main(String<> args) int w = -5 + 8 * 6; int x = (55 + 9) % 9; int y = 20 + (-3 * 5 / 8); int z = 5 + 15 / 3 * 2 - 8 % 3; System.out.print(w + "\n" + x + "\n" + y + "\n" + z); Flowchart:

*

Java code Editor:

contribute your code and also comments through Disqus.

You are watching: 4 * 3 / 8 + 2.5 * 2

Previous: write a Java regimen to divide two numbers and print on the screen.Next: write a Java routine that takes 2 numbers as input and also display the product of 2 numbers.


What is the an obstacle level of this exercise?

EasyMediumHard


Java: tips of the Day

Java Classes

A Java course is declared with the keywords public class together with a unique course name mirroring its paper name. Because that example, in a paper Hello.java in project helloworld:

package helloworld;import javax.swing.*;import java.awt.*;import java.awt.event.*;/** *
author seth * A GUI hello world. */public class Hello // this is an empty classYou deserve to declare variables and functions within a class. In Java, variables in ~ a class are referred to as fields.

Ref: https://red.ht/3sL3sSl


New Content released on starrkingschool.net:

Because of specific maintenance issues of our servers and financial constraints, we are closing our commenting mechanism for the time being. We may resume the in the near future.

See more: The Plight Of American Farmers During The Depression Was Magnified By


This work is licensed under a creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.