三楼高层采光如何:那位老大帮帮我做作这些问题?????

来源:百度文库 编辑:神马品牌网 时间:2024/05/08 14:29:01
Java Programming 1: LAB 4

Note: You have to show the answers to the tutor during the lab hours. The tutor will assess anyour answers d mark will be awarded to those students who finish this exercise.

Objectives:
• To be able to display message/ get input by using JOptionPane class
• To be able to use arithmetic operators.
• To understand the precedence of arithmetic operators.

Question 1:

// Example which display text using dialog box
import javax.swing.JOptionPane;
class LabExerciseGUI
{
public static void main(String[ ] args)
{
JOptionPane.showMessageDialog(null,
"Jennifer \n 1000123456 \n 1980 \n\n Good Luck");
System.exit(0);
} // end main
} // end class

Program 1

Copy the above LabExerciseGUI class. Modify the it with your own name, your ID number, Date of Birth and a message. The following is the example output *.

* Note: Please note the icon used, the title bar, the spacing in the dialog box

Question 2:
Write an application that inputs three integers from the user and displays the:
sum
multiplication
average
an information message dialog.
[Note: The calculation of the average in this exercise should be represented as an integer.]

The Output should look like the screen shot in page 2.

Question 3:
Manually calculate the output for each of the system print statement.
Copy and try to run the given source code in JCreator.
Compare your answer with the computer generate output.

抱歉,只能用C++来解决你的第二个问题,

#include <iostream>
using namespace std;

int main(){
int a,b,c,sum,multiplication,average;
cout<<"Input a:";
cin>>a;

cout<<"Input b:";
cin>>b;

cout<<"Input c:";
cin>>c;

sum=a+b+c;
multiplication=a*b*c;
average=sum/3;

cout<<"The sum is "<<sum
<<",the multiplication is "
<<multiplication<<endl;
<<"and the average is "<<average;

return 0;
}

上面的代码没有经过调试,你可以试一下,
我不会JAVA,但是C++和JAVA很像,相信你有能力将其
转换成JAVA代码。

另外,你说的那个screen shot in page 2. 并没有给出,因此我没有办法做到像你所说第二页中的那个截图完全相同。还是很抱歉其他两题我也不会。。