Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.text.Format;
- public class metdBisseccao {
- public static void main(String[] args) {
- double a = 2.5;
- double b = 3;
- double Cn = 0;
- double funcao = 0;
- for (int i = 0; i < 7; i++) {
- Cn = (a + b) / 2;
- funcao = Math.pow(Cn, 3) - (Cn * 9) + 5;
- if (funcao == 0) {
- System.out.println("f(c) = 0");
- break;
- } else {
- if (funcao > 0) {
- b = Cn;
- } else if (funcao < 0) {
- a = Cn;
- }
- }
- }
- System.out.println("Cn é: " + Cn);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement