Write a program to print the sum of two linear equations by creating a class named as ‘LinearEquations’ containing two data members, a and b and two functions. First function named as ‘add’ adds the given two linear equations and updates the first linear equation with the result and the second function named as ‘print’ prints the given sum in the format ‘ax + b’ where a is the coefficient of x and b is the constant. Take a and b of both the linear equations as input from scanner. Consider a and b to be positive integers. Input Format : Line 1 : Two integers- a and b of 1st linear equation Line 2 : Two integers- a and b of 2nd linear equation Sample Input 1 : 2 3 1 5 Sample Output 1 : 3x + 80 pls solve this program elaboratrely in java
Write a program to print the sum of two linear equations by creating a class named as
‘LinearEquations’ containing two data members, a and b and two functions. First function named
as ‘add’ adds the given two linear equations and updates the first linear equation with the result and
the second function named as ‘print’ prints the given sum in the format ‘ax + b’ where a is the
coefficient of x and b is the constant. Take a and b of both the linear equations as input from
scanner. Consider a and b to be positive integers.
Input Format :
Line 1 : Two integers- a and b of 1st linear equation
Line 2 : Two integers- a and b of 2nd linear equation
Sample Input 1 :
2 3
1 5
Sample Output 1 :
3x + 80
pls solve this program elaboratrely in java
Step by step
Solved in 3 steps with 2 images