Management Information system – writing a Java statement

Management Information system – writing a Java statement
Introductory Programming for Information Systems

1) Write a Java statement to accomplish each of the following tasks:

a) Declare variables sum and x to be of type int.
b) Assign 1 to variable x.
c) Assign 0 to variable sum.
d) Add variable x to sum, and assign the result to variable sum.
e) Print “The sum is: “, followed by the value of variable sum.

2) Combine the statements that you wrote into a Java application that calculates and prints the sum of integer from 1 to 10. Use the while loop through the calculation and increment statements. The loop should terminate when the value of x become 11.
3) Write a java statement or a set of java statements to accomplish each of the following tasks:

a) Sum the odd integers between 1 and 99, using a for statement. Assume that the integers variables sum and count have been declared.
b) Calculate the value of 2.5 raised to the power of 3 using the pow method.
c) Print the integers from 1 to 20, using the while loop the counter variable i. Assume that the variable ithas been declared, but no initialized. Print only five integers per line. [ Hint: Use the calculation i % 5. When the value of this expression is 0, print a newline character; otherwise, print a tab character. Assume that this code is an application. UseSystem.out.println(‘\t’)method to output the tab character .]
d) Repeat part (c), using for statement
4) Write a java program that displays a student’s status based on the following codes:

Code Student Status
1 Freshman
2 Sophomore
3 Junior
4 Senior

READ ALSO :   Political science

Your program should accept the code number as a user-entered input value and based on this value display the correct student status. If an incorrect code is entered, your program should display the string “An incorrect code was entered”.