Professional Documents
Culture Documents
Programming 2 Workshop 2
Programming 2 Workshop 2
BU/17C/IT/2684
package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
//1. Write a program to find the roots of quadratic equation using the formula: Equation: ax^2+bx+c
//Discriminant: b^2-4ac
//Root1 = (-b+√d/2a
//Root2 = (-b-√d/2a
Scanner sc = new Scanner(System.in);
System.out.println("Enter the value of a ::");
double a = sc.nextDouble();
2b)package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
}
}
3)
}
(i)I am tabbed
(ii) new
line
(iii)backslash \
(v)backspace
4)a
package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
}
}\
4)b
package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
}
}
5)package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
//Declare three variables of type String (str1, str2, str3), one should be an empty string and
// concatenate the three strings.
String str1;
String str2;
String str3;
import java.util.Scanner;
//6.(a) What does the following program do. Run and write comments about the program.
//x = 1;
//y = ++x
int x = 1;
int y = ++x;
System.out.println(y);
//The following program incrememts x by 1
}
}
6 6b) package ng.edu.baze.com.com3131_2021Q2;
import java.util.Scanner;
//6.(a) What does the following program do. Run and write comments about the program.
//x = 1;
//y = x++
int x = 1;
int y = x++;
System.out.println(y);
//The following program prints 1
}
}