JAVA设计一个Applet,完成一份调查问卷,至少包括五个题目,

JAVA设计一个Applet,完成一份调查问卷,至少包括五个题目,,第1张

import java.applet.Applet

import java.awt.Color

import java.awt.Font

import java.awt.Graphics

public class DrawString extends Applet {

public void paint(Graphics g)

{

g.setFont(new Font("宋体",Font.BOLD,36))

g.setColor(Color.green)

g.drawString("这是一个Java Applet程序",5,30)

g.setColor(Color.red)

g.drawString("欢迎学习Java",5,80)

}

}

1------------------------------------------------------------------------------

import java.util.Scanner

public class Main {

public static void main(String[] args) throws IOException{

Scanner scan = new Scanner(System.in)

System.out.println("输入一个整数:")

int num = scan.nextInt()

char[] numChar = Integer.toString(num).toCharArray()

for(int i = 0i<numChar.lengthi++) {

System.out.println(numChar[i])

}

}

}

2-----------------------------------------------------

public class Text2 {

public static void main(String[] args) {

int j = 0, k = 0

for (int i = 1 i <= 100i++) {

if (i % 2 == 0) {

j += i

} else {

k += i

}

}

System.out.println("偶数和为:" + j)

System.out.println("奇数和为:" + k)

}

}

3------------------------------------------------------------------------

import java.util.*

public class Test {

public static void main(String[] args) {

Scanner san = new Scanner(System.in)

int aint = 0

System.out.print("请输入一个整数: ")

aint = san.nextInt()

System.out.println(aint + "的二进制表示为: " + Integer.toBinaryString(aint))

}

}

4--------------------------------------------------------------------------------

public class text {

public static void main(String args[]) {

text t = new text()

System.out.print(t.sum())

}

public int sum(){

int a = 0

for(int i=1i<=10i++){

int b = 1

for (int j = 1j <=ij++) {

b = b*j

}

a=a+b

}

return a

}

}

4.2----------------------------------------------------------

import java.io.*

public class jiecheng

{

public static long fac(int n)

{long res=1

for(int k=2k<=nk++)

res*=k

return res}

public static void main(String args[]) throws IOException

{long sum=0int i=1,n=20

for(i=1i<=ni++)

sum+=fac(i)

System.out.println("前"+n+"项阶乘的为:"+sum)

}

}

5--------------------------------------------------------------------------

public class Dy3 {

public static void main(String[] args) {

int sum = 0 //素数

String s=""//素数

boolean y = true

for(int i = 100 i <= 1000 i++){

y=true//为每个数初始化y为真

for(int j = 2 j <i j++){

if(i % j == 0){

y = false//被除了1和本身以外的数整除为false

break

}

}

if(y)

{

s+=i+" "

sum+=i

}

}

System.out.println("素数为:"+s)

System.out.println("素数和为:"+sum)

}

}

6--------------------------------------------------------------

public class Demo{

public static void main(String args[]){

int i,j

for(i=1i<10i++)

{

for(j=1j<=ij++) //此处如果想输入完全的9x9则将j<=i改为j<10

{

System.out.print(j+"*"+i+"="+i*j+"\t")

}

System.out.println()

}

}

}

首先创建一个连接工厂import java.sql.Connection

import java.sql.DriverManager

import java.sql.ResultSet

import java.sql.Statementpublic class ConnectionFactory {

private Connection conn=null

private Statement stmt=null

private ResultSet rs=null

public ConnectionFactory() {

super()


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/bake/11590031.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-17
下一篇 2023-05-17

发表评论

登录后才能评论

评论列表(0条)

保存