The first process assessment--structural programming

Source: Internet
Author: User

Address of the Code cloud Warehouse: Https://gitee.com/wslgx/codes

7-1 Hello world! (5 points)

The subject asks to write a program, output a short phrase "Hello world!".

Input format:

This topic is not entered.

Output format:

Output the phrase "Hello world!" in a row.

Program Design ideas: directly in the output code to fill in the content to be output.

Knowledge Points: System.out.println ("content to output");.

Operation Result:

7-2 for 1 to 100 and (10 points)

To write a program, calculate the expression 1 + 2 + 3 + ... + 100 value.

Input format:

No input in the subject.

Output format:

Output in the following format:

sum = 累加和

The design idea of the program : Use the FOR Loop statement with Sum=sum+i to complete the summation.

Knowledge Point:A For loop statement.

Operation Result:

7-3 sectional calculation of water consumption (15 points)

In order to encourage the residents to save water, the water company adopts a ladder-based pricing method, the residents should pay the charges.Y (yuan) and monthly water consumptionX (ton) Related: whenx no more than 15 tons, y =4x/3; over, y =2. 5x? 17. 5. Please write a program to achieve the calculation of water charges.

Input format:

The input gives a non-negative real number x in a row .

Output format:

The water charges that should be handed out on a line are accurate to 2 digits after the decimal point.

Input Sample 1:
12
Output Example 1:
16.00
Input Sample 2:
16
Output Example 2:

 22.50

The design idea of the program: use if () else if () statement to select two charge conditions, and then the number of the decimal point after the two digits of the precise output.

Knowledge Point:if SELECT statement; scanner input statement; printf controls output precision.

Operation Result:

7-4 printing 99 tables (20 points)

Below is a complete lower triangle 99 tables:

1*1=1   1*2=2   2*2=4   1*3=3   2*3=6   3*3=9   1*4=4   2*4=8   3*4=12  4*4=16  1*5=5   2*5=10  3*5=15  4*5=20  5*5=25  1*6=6   2*6=12  3*6=18  4*6=24  5*6=30  6*6=36  1*7=7   2*7=14  3*7=21  4*7=28  5*7=35  6*7=42  7*7=49  1*8=8   2*8=16  3*8=24  4*8=32  5*8=40  6*8=48  7*8=56  8*8=64  1*9=9   2*9=18  3*9=27  4*9=36  5*9=45  6*9=54  7*9=63  8*9=72  9*9=81  

The subject asks for any given positive integer N , the output from 1*1 N*N the partial table.

Input format:

The input gives a positive integer N (1≤ N ≤9) in a row.

Output format:

Output the lower triangular N*N table, where the right digit equals 4 digits, left-aligned.

Input Sample:
4
Sample output:
1*1=1   1*2=2   2*2=4   1*3=3   2*3=6   3*3=9   1*4=4   2*4=8   3*4=12  4*4=16  
程序的设计思路:利用for循环结构的嵌套来输出乘法表,并利用printf的左对齐来使结果对齐。
知识点:
for循环结构的嵌套;printf可使输出左对齐。
运行结果:
Learning content Number of lines of code Blog words
Getting Started with Java 15
Input/Output data 49
Conditional branching statements 22
Looping statements 90
First-time Process assessment 44 488

The first process assessment--structured programming

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.