Advertisement
Guest User

Untitled

a guest
Jan 11th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package javaapplication1;
  7.  
  8. import java.util.Scanner;
  9.  
  10. /**
  11. *
  12. * @author Osobuke
  13. */
  14. public class Ejercicio3 {
  15. public static void main(String []args){
  16. Scanner introducir = new Scanner(System.in);
  17. int a,b,c,d,p;
  18. do {
  19. System.out.print("Introduce el número de valores mayor a 0: ");
  20. p = introducir.nextInt();
  21. } while (p<0);
  22.  
  23. do{
  24. System.out.print("Introduzca el coeficiente a mayor a 0: ");
  25. a = introducir.nextInt();
  26. } while (a<0);
  27. do{
  28. System.out.print("Introduzca el coeficiente b mayor a 0: ");
  29. b = introducir.nextInt();
  30. } while (b<0);
  31. do{
  32. System.out.print("Introduzca el coeficiente c mayor a 0: ");
  33. c = introducir.nextInt();
  34. } while (c<0);
  35. do{
  36. System.out.print("Introduzca el coeficiente d mayor a 0: ");
  37. d = introducir.nextInt();
  38. } while (d<0);
  39. //EXPRESIÓN: a*x^3+b*x^2+c*x^1+d*x^0
  40. int j=0;
  41. for (int x=0;x<p;x++){
  42. j=(a*(x*x*x))+(b*(x*x))+(c*x)+d*1;
  43. System.out.print(x+" |");
  44. for (int i=0;i<j;i++){
  45. System.out.print(" ");
  46. }
  47. System.out.println("*");
  48. }
  49. }
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement