Advertisement
Guest User

Main_Signals

a guest
May 24th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.43 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class Main_Signals {
  5.  
  6.     public static void main(String[] args) {
  7.         // TODO Auto-generated method stub
  8.         double temp=0;
  9.         int x1=0,x2=0;
  10.         boolean f= false;
  11.         //creating objects
  12.         Scanner keyboard = new Scanner(System.in);
  13.         Signals []waves= new Signals[2];
  14.         //getting values for signal waveforms from user
  15.         for (int i=0;i<2;i++)
  16.         {
  17.             waves[i] = new Signals();
  18.             System.out.println("Enter parameter for object"+(i+1)+", a =");
  19.             temp = keyboard.nextDouble();
  20.             waves[i].amplitude= temp;
  21.             System.out.println("Enter parameter for object"+(i+1)+", b =");
  22.             temp = keyboard.nextDouble();
  23.             waves[i].offsetValue= temp;
  24.         }      
  25.         //getting start and end values of x from user
  26.         do
  27.         {
  28.             System.out.println("Enter start value for x, x1 =");
  29.             x1 = keyboard.nextInt();
  30.             System.out.println("Enter end value for x, x2 =");
  31.             x2 = keyboard.nextInt();
  32.             if (x1<=x2)
  33.             {
  34.                 f = true;
  35.             }
  36.             else
  37.             {
  38.                 System.out.println("Incorrect input, please make x1 smaller or equal to x2.");
  39.             }          
  40.         }
  41.         while (f == false);// it only progress if x1 is smaller or equal to x2
  42.        
  43.         //getting and printing
  44.         for (int i=0;i<2;i++)
  45.         {
  46.             System.out.print("The values of signal "+(i+1)+" are: [");
  47.             for (int j=x1;j<=x2;j++)
  48.             {
  49.                 System.out.print(waves[i].getY(j));
  50.                 if (j<x2)
  51.                 System.out.print(", ");
  52.             }
  53.             System.out.print("]\n");
  54.         }
  55.         keyboard.close();
  56.     }
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement