Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public static void main(String[] args) {
Scanner scanner = new Scanner( System.in );
char OK = 'Y';
int a,b;
double x;
do
{
System.out.print("Nhap a = ");
a = Integer.parseInt(scanner.nextLine() );
System.out.print("Nhap b = ");
b = Integer.parseInt(scanner.nextLine() );
if(a==0)
System.out.printf("Phuong trinh %dx + %d = 0 vo nghiem",a,b);
else
{
x = -b/(a*1.0);
System.out.printf("Phuong trinh %dx + %d = 0 co nghiem x = %.2f",a,b,x);
}
System.out.print("Ban co muon tiep tuc?(Y/N)");
OK = scanner.nextLine().charAt(0);
} while(OK != 'N');
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.