Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package javaapplication1;
- import java.util.Scanner;
- /**
- *
- * @author Osobuke
- */
- public class Ejercicio3 {
- public static void main(String []args){
- Scanner introducir = new Scanner(System.in);
- int a,b,c,d,p;
- do {
- System.out.print("Introduce el número de valores mayor a 0: ");
- p = introducir.nextInt();
- } while (p<0);
- do{
- System.out.print("Introduzca el coeficiente a mayor a 0: ");
- a = introducir.nextInt();
- } while (a<0);
- do{
- System.out.print("Introduzca el coeficiente b mayor a 0: ");
- b = introducir.nextInt();
- } while (b<0);
- do{
- System.out.print("Introduzca el coeficiente c mayor a 0: ");
- c = introducir.nextInt();
- } while (c<0);
- do{
- System.out.print("Introduzca el coeficiente d mayor a 0: ");
- d = introducir.nextInt();
- } while (d<0);
- //EXPRESIÓN: a*x^3+b*x^2+c*x^1+d*x^0
- int j=0;
- for (int x=0;x<p;x++){
- j=(a*(x*x*x))+(b*(x*x))+(c*x)+d*1;
- System.out.print(x+" |");
- for (int i=0;i<j;i++){
- System.out.print(" ");
- }
- System.out.println("*");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement