Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

77. Create a program that solves liner equations (y=ax+b) first program ask the

ID: 3865167 • Letter: 7

Question

77. Create a program that solves liner equations (y=ax+b)
first program ask the user to enter value for a and b
and the program should display(All solution(if both a and b is 0), no solution(if b is not equal to 0) if a is not equal to 0 the it should print one solution with the exact value )
and after that program should ask the user if they want to solve more liner equation.
USE do while.

78.Create a program that solves liner equations (y=ax+b)
program should ask the user how many liner equation they want the program to solve .
the program should display(All solution(if both a and b is 0), no solution(if b is not equal to 0) if a is not equal to 0 the it should print one solution with the exact value )
program should end after it has completed all the line equation request
if the user entered they want to solve 0 liner equation program should end right there

in java

Explanation / Answer

Answer:

77. Here's the program for question 77:

import java.util.*;
public class MyClass {
public static void main(String args[]) {
char x = 'y';
Scanner sc = new Scanner(System.in);
do{
System.out.print(" Enter value for a: ");
int a = sc.nextInt();
sc.nextLine();
System.out.print(" Enter value for b: ");
int b = sc.nextInt();
sc.nextLine();
if(a==0 && b==0){
System.out.println(" All Solution");
}
if(b != 0){
System.out.println("No Solution");
}
if(a != 0 && b==0){
System.out.println("Solution: ");
System.out.println("x=2 y="+(2*a));
}
System.out.println("Do you want to solve more equations. Enter y/n:");
x = sc.next().charAt(0);
}while(x == 'y');
sc.close();
}
}

OUTPUT:

Enter value for a: 0

Enter value for b: 0

All Solution
Do you want to solve more equations. Enter y/n:
y

Enter value for a: 1

Enter value for b: 0
Solution:
x=2   y=2
Do you want to solve more equations. Enter y/n:

n

78. Here's the program for question 78:

import java.util.*;
public class MyClass {
public static void main(String args[]) {
int x = 9;
Scanner sc = new Scanner(System.in);
System.out.println("How many linear equations do you want to solve?");
x = sc.nextInt();
sc.nextLine();
if(x == 0){
return;
}
else{
for(int c = x; c>0; c--){
System.out.print(" Enter value for a: ");
int a = sc.nextInt();
sc.nextLine();
System.out.print(" Enter value for b: ");
int b = sc.nextInt();
sc.nextLine();
if(a==0 && b==0){
System.out.println(" All Solution");
}
if(b != 0){
System.out.println("No Solution");
}
if(a != 0 && b==0){
System.out.println("Solution: ");
System.out.println("x=2 y="+(2*a));
}
}
}
sc.close();
}
}

OUTPUT:

How many linear equations do you want to solve?
2

Enter value for a: 1

Enter value for b: 1
No Solution

Enter value for a: 3

Enter value for b: 0
Solution:

x=2   y=6

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote