Answer:g
public static int addOddMinusEven(int start, int end){
int odd =0;
int even = 0;
for(int i =start; i<end; i++){
if(i%2==0){
even = even+i;
}
else{
odd = odd+i;
}
}
return odd-even;
}
}
Explanation:
Using Java programming language:
- The method addOddMinusEven() is created to accept two parameters of ints start and end
- Using a for loop statement we iterate from start to end but not including end
- Using a modulos operator we check for even and odds
- The method then returns odd-even
- See below a complete method with a call to the method addOddMinusEven()
public class num13 {
public static void main(String[] args) {
int start = 2;
int stop = 10;
System.out.println(addOddMinusEven(start,stop));
}
public static int addOddMinusEven(int start, int end){
int odd =0;
int even = 0;
for(int i =start; i<end; i++){
if(i%2==0){
even = even+i;
}
else{
odd = odd+i;
}
}
return odd-even;
}
}
Answer:
Following are the code in the Java Programming Language:
try{ //try block.
processor.process(); //
call the function through the object.
}
catch(Exception e){ //catch block .
System.out.println( "process failure"); //if any exception occurs then print.
}
Explanation:
In the following code, we set two blocks in Java Programming Language of the exception handling which is try block or catch block.
- In try block we call the function "process()" through the "processor" object.
- If any exception occurs in the program then the catch block print the following message is "process failure"
Answer:
// here is code in java.
public class NAMES
{
// main method
public static void main(String[] args)
{
int n=4;
// print the upper half
for(int a=1;a<=n;a++)
{
for(int b=1;b<=n-a;b++)
{
// print the spaces
System.out.print(" ");
}
// print the * of upper half
for(int x=1;x<=a*2-1;x++)
{
// print the *
System.out.print("*");
}
// print newline
System.out.println();
}
// print the lower half
for(int y=n-1;y>0;y--)
{
for(int z=1;z<=n-y;z++)
{
// print the spaces
System.out.print(" ");
}
for(int m=1;m<=y*2-1;m++)
{
// print the *
System.out.print("*");
}
// print newline
System.out.println();
}
}
}
Explanation:
Declare a variable "n" and initialize it with 4. First print the spaces (" ") of the upper half with the help of nested for loop.Then print the "*" of the upper half with for loop. Similarly print the lower half in revers order. This will print the required shape.
Output:
*
***
*****
*******
*****
***
*
Answer:
a. WS-Trust
Explanation:
WS-Trust can be defined as a WS-specification as well as OASIS standard that help to provides extensions to WS-Security, in order to facilitate a mechanism for issuing, renewing, as well as validating of security tokens which is why the aim and objectives of WS-Trust is to help and enable applications to construct trusted SOAP message exchanges.
Nevertheless WS-Trust enables the issuance as well as the dissemination of credentials within several and various trust domains.
Answer:
Following are the error in the given program are explain in the explanation part .
Explanation:
The main() function call the function getMileage() function after that the control moves to the getMileage() definition of function. In this firstly declared the "mileage" variable after that it taking the input and module is finished we see that the "mileage" variable is local variable i,e it is declared inside the " Module getMileage() " and we prints in the main module that are not possible to correct these we used two technique.
Technique 1: Declared the mileage variable as the global variable that is accessible anywhere in the program.
Technique 2: We print the value of "mileage" inside the Module getMileage() in the program .