Using Labview Construct a VI that could calculate the sum o

Using Labview, Construct a VI that could: - calculate the sum of a series of continuous integer numbers from 1 to given integer N. Sum=1+2+3+…+N (Tip: “While Loop” may be needed for calculation)
- calculate the sum of a series of continuous odd numbers from 1 to given odd number N. Sum=1+3+5+…+ N (Tip: “While Loop” may be needed for calculation)
-calculate the sum of a series of continuous even numbers from 1 to given odd number N. Sum=1+3+5+…+ N (Tip: “While Loop” may be needed for calculation)

Solution

Answer:

1)

import java.util.*;
public class Sumnumbers
{
public static void main(String args[])
{
int input, i = 1 ;
int total = 0;
System.out.println(\"Enter the value of n :\");
Scanner s = new Scanner(System.in);
input = s.nextInt();
while(i <= input)
{
total = total +i;
i++;
}
System.out.println(\"The sum of numbers is :\"+total);
}
}

2)

import java.util.*;
public class Sumofodd
{   
public static void main ( String[] args )
{
int odd = 1;
int sumodd = 0;
  
System.out.println(\"Enter Number of items :\");
Scanner s = new Scanner(System.in);
int input = s.nextInt();
while ( odd <= input )
{
sumodd = sumodd + odd;
odd = odd + 2;
}   
System.out.printf ( \"Total sum of the odd number is\"+sumodd);

  
}
}

3)

import java.util.*;
public class Sumofeven
{   
public static void main ( String[] args )
{
  
int even = 2;
int sumeven = 0;
System.out.println(\"Enter value of n :\");
Scanner s = new Scanner(System.in);
int input = s.nextInt();

while (even <=input)
{
sumeven = sumeven + even;
even = even + 2;
}
System.out.printf ( \"Sum of the even numbers is\"+ sumeven);
}
}

Using Labview, Construct a VI that could: - calculate the sum of a series of continuous integer numbers from 1 to given integer N. Sum=1+2+3+…+N (Tip: “While Lo
Using Labview, Construct a VI that could: - calculate the sum of a series of continuous integer numbers from 1 to given integer N. Sum=1+2+3+…+N (Tip: “While Lo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site