Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main_Signals {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- double temp=0;
- int x1=0,x2=0;
- boolean f= false;
- //creating objects
- Scanner keyboard = new Scanner(System.in);
- Signals []waves= new Signals[2];
- //getting values for signal waveforms from user
- for (int i=0;i<2;i++)
- {
- waves[i] = new Signals();
- System.out.println("Enter parameter for object"+(i+1)+", a =");
- temp = keyboard.nextDouble();
- waves[i].amplitude= temp;
- System.out.println("Enter parameter for object"+(i+1)+", b =");
- temp = keyboard.nextDouble();
- waves[i].offsetValue= temp;
- }
- //getting start and end values of x from user
- do
- {
- System.out.println("Enter start value for x, x1 =");
- x1 = keyboard.nextInt();
- System.out.println("Enter end value for x, x2 =");
- x2 = keyboard.nextInt();
- if (x1<=x2)
- {
- f = true;
- }
- else
- {
- System.out.println("Incorrect input, please make x1 smaller or equal to x2.");
- }
- }
- while (f == false);// it only progress if x1 is smaller or equal to x2
- //getting and printing
- for (int i=0;i<2;i++)
- {
- System.out.print("The values of signal "+(i+1)+" are: [");
- for (int j=x1;j<=x2;j++)
- {
- System.out.print(waves[i].getY(j));
- if (j<x2)
- System.out.print(", ");
- }
- System.out.print("]\n");
- }
- keyboard.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement