2021级-JAVA01 Java入门编程题


7-1 模仿练习

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println("Programming is fun!");
        System.out.println("Fundamentals First");
        System.out.println("Problem Driven");
    }
}

7-2 Hello World!

public class Main {
    public static void main(String[] args) throws Exception {
        System.out.println("Hello World!");
    }
}

7-3 sdut-入门-交换两个整数的值

import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner reader = new Scanner(System.in);
        int a, b, temp;
        a = reader.nextInt();
        b = reader.nextInt();
        temp = a;
        a = b;
        b = temp;
        System.out.print(a + " " + b);
        reader.close();
    }
}

7-4 sdut-入门-转换字母

import java.util.*;

public class Main {
    public static void main(String[] args){
        String a;
        Scanner input = new Scanner(System.in);
        a = input.nextLine();
        System.out.println(a.toUpperCase());
        input.close();
    }
}

7-5 球的表面积和体积

import java.util.Scanner;
import java.text.DecimalFormat;
public class Main
{
    public static void main(String[] args)
    {
        Scanner reader = new Scanner(System.in);
        double d1 = reader.nextDouble();
        double s, v, p;
        p = 3.1415926535;
        s = 4 * d1 * d1 * p;
        v = (4 * p * d1 * d1 * d1) / 3;
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.print(df.format(s) + " " + df.format(v));
    }
}

7-6 华氏温度转化为摄氏温度

import java.text.DecimalFormat;
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner in = new Scanner(System.in);
        double c;
        double f = in.nextDouble();
        c = (f - 32) * 5 / 9;
        DecimalFormat df = new DecimalFormat("0.00");
        System.out.println("c="+df.format(c));
        in.close();
    }
}

7-7 sdut-入门-1 A+B for Input-Output Practice(I)

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner reader = new Scanner(System.in);
        int a, b, c;
        while(reader.hasNext())
        {
            a = reader.nextInt();
            b = reader.nextInt();
            c = a + b;
            System.out.println(c);
        }
        reader.close();
    }
}


7-8 sdut-入门-2 A+B for Input-Output Practice (II)

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner reader = new Scanner(System.in);
        int a, b, m, c;
        m = reader.nextInt();
        while(m-- >0)
        {
            a = reader.nextInt();
            b = reader.nextInt();
            c = a + b;
            System.out.println(c);
        }
        reader.close();
    }
}

7-9 sdut0-入门-3 A+B for Input-Output Practice (III)

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        while(in.hasNext())
        {
            int a, b;
            a = in.nextInt();
            b = in.nextInt();
            if(a == 0 && b == 0) break;
            System.out.println(a + b);
        }
    }
}


7-10 sdut-入门-4 A+B for Input-Output Practice (IV)

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        while(in.hasNext())
        {
            int n = in.nextInt();
            if(n == 0) break;
            int sum = 0;
            for(int i = 0; i < n; i ++)
            {
                int x = in.nextInt();
                sum += x;
            }
            System.out.println(sum);
        }
    }
}


7-11 sdut-入门-5 A+B for Input-Output Practice (V)

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner reader = new Scanner(System.in);
        int x, n, m;
        m = reader.nextInt();
        while(m-- >0)
        {
            x = 0;
            n = reader.nextInt();
            while(n-- > 0)
            {
                x += reader.nextInt();
            }
            System.out.println(x);
        }
        reader.close();
    }
}

7-12 sdut-入门-6 A+B for Input-Output Practice (VI)

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        while(in.hasNext())
        {
            int n = in.nextInt();
            int sum = 0;
            for(int i = 0; i < n; i ++)
            {
                int x = in.nextInt();
                sum += x;
            }
            System.out.println(sum);
        }
    }
}


7-13 sdut-入门-7 A+B for Input-Output Practice (VII)

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        Scanner in = new Scanner(System.in);
        while(in.hasNext())
        {
            int a = in.nextInt();
            int b = in.nextInt();
            System.out.println(a + b);
            System.out.println();
        }
    }
}

7-14 sdut-入门-8 A+B for Input-Output Practice(VIII)

import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scanner reader = new Scanner(System.in);
        int x, n, m;
        m = reader.nextInt();
        while(m-- >0)
        {
            x = 0;
            n = reader.nextInt();
            while(n-- > 0)
            {
                x += reader.nextInt();
            }
            System.out.println(x);
            System.out.println();
        }
        reader.close();
    }
}

7-15 打印字母B。

import java.util.Scanner;

public class Main
{
    public static void main(String[] args)
    {
        System.out.println("*****");
        System.out.println("*   *");
        System.out.println("*****");
        System.out.println("*   *");
        System.out.println("*****");
    }
}

  • 5
    点赞
  • 11
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
Java入门编程是指初学者学习并掌握Java编程语言的基础知识和技能。Java语言以其简洁、可移植性强和面向对象的特性,成为了广泛应用于软件开发领域的一门语言。对于初学者而言,一本Java入门编程的PDF教材是帮助他们快速入门的重要资源。 一本好的Java入门编程PDF教材应该具备以下几个特点: 1.系统性:教材应该从基本概念开始,逐步介绍一些关键概念,例如变量、数据类型、运算符和控制流程等。然后逐渐深入,介绍面向对象编程的基本原则和技巧,以及常用的Java核心类和API。 2.易于理解:教材应该以通俗易懂的语言来描述Java编程的概念和技术。避免使用过于复杂的术语和专业名词,尽量采用简单明了的示例来解释复杂的概念,帮助初学者更好地理解。 3.实践性:教材应该提供大量的编程实例和练习题,让学习者通过实践运用所学的知识,加深对Java编程的理解和掌握。 4.覆盖全面:教材应该涵盖Java编程的各个方面,包括基本语法、面向对象编程、异常处理、多线程编程和IO 进出光、网络编程等。这样可以帮助学习者更全面地了解和应用Java编程的各个方面。 5.更新及时:由于Java编程语言不断更新和演进,教材需要不断更新以保持与最新版本的Java语言和技术的一致。 总之,一本好的Java入门编程PDF教材可以帮助初学者系统、轻松地学习并掌握Java编程的基础知识和技能。通过不断的学习和实践,初学者可以逐渐提升自己的编程能力,成为一名合格的Java开发者。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值