Question
27.4 Week 1: Expressions*: Simple floating-point expression Version 2 Write an assignment statement for the following mathematical equation: y = (2/7)x + (x/9) + 23x
27.4 Week 1: Expressions*: Simple floating-point expression Version 2
Write an assignment statement for the following mathematical equation:
y = (2/7)x + (x/9) + 23x
Keep x as an integer. Use an expression that matches the equation's right side as closely as possible. If the input is -1, the output is -23.396825396825395.
Hints:
Don't rearrange the equation or try to simplify it.
If both operands of division (or other operators) are integers, integer division is performed, which rounds down; so for example 1/2 is 0. So make at least one operand a floating-point type, as in 2.0/7, or 2.0/7.0, to cause floating-point division.
import java.util.Scanner;
public class Main { public static void main(String[] args) { Scanner scnr = new Scanner(System.in); int x; double y; x = scnr.nextInt(); /* Type your code here. */ System.out.println(y); } }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started