1. Enter your own salary to calculate the personal income tax: according to the current tax rate (find your own tax rate)
public static void Main (string[] args) {
System.out.println ("Please enter your salary:");
Scanner sc=new Scanner (system.in);
Double money=sc.nextdouble ();
Double total=0.0;
total=money-3500;
Double revenue=0.0;
if (total<=0) {
System.out.println ("Congratulations, no watering");
}
else if (total<=1500) {
revenue=total*0.03;
}
else if (total>1500&&total<=4500) {
revenue=1500*0.03+ (total-1500) *0.1;
}
else if (total>4500&&total<=9000) {
revenue=1500*0.03+3000*0.1+ (total-4500) *0.2;
}else if (total>9000&&total<=35000) {
revenue=1500*0.03+3000*0.1+4500*0.2+ (total-9000) *0.25;
}
else if (total>35000&&total<=55000) {
revenue=1500*0.03+3000*0.1+4500*0.2+26000*0.25+ (total-35000) *0.30;
}
else if (total>55000&&total<=80000) {
revenue=1500*0.30+3000*0.1+4500*0.2+26000*0.25+20000*0.30+ (total-55000) *0.35;
}
else if (total>80000) {
Revenue = 1500 * 0.03 + 3000*0.1 + 4500*0.2 + 26000*0.25 + 20000*0.3 + 35000*0.35 + (total-80000) *0.45;
}
SYSTEM.OUT.PRINTLN ("You pay the personal income tax is:" +revenue);
}
2. Write a Java application. Users enter a number from the keyboard between 1-9999, the program will determine the number of digits, and determine whether this number is a palindrome number. Palindrome number refers to the number of numbers contained in reverse order after the number and the original number of the same, such as 12121, 3223 are palindrome number
public static void Main (string[] args) {
TODO auto-generated Method Stub
System.out.println ("Please enter a number:");
Scanner sc=new Scanner (system.in);
String A=sc.nextline ();
StringBuffer sb=new StringBuffer (a);
String B=new string (Sb.reverse ());
if (A.equals (b)) {
System.out.println ("palindrome number");
}
else {
System.out.println ("not palindrome number");
}
int Changdu=a.length ();
System.out.println (Changdu);
for (int i=changdu-1;i>=0;i--) {
if (A.charat (i)!= ' ") {
System.out.println ("The number" + (i+1) + "bit");
Break
}
}
System.out.println (h);
}
The answer is at the bottom.
First, the design of a program to complete the following content:
= = = Welcome to use = = =
| 1. Find the maximum value |
| 2. Find the Minimum value |
| 3. Find the index value |
| 4. Square root |
| 5. Exit |
===========
Please choose:
1.
Please enter the first number:
Please enter a second number:
The larger numbers in X and Y are:
2.
Please enter the first number:
Please enter a second number:
The smaller numbers in X and Y are:
3.
Please enter the base:
Please input index:
The y-square of X is:
4.
Please enter the square number:
The square root of X is:
5. Thank you for using:)
Second, graphic printing
Hollow Rectangle:
**********
* *
* *
* *
**********
Filled Rectangle:
##########
##########
##########
##########
##########
Hollow Upper Triangular (right):
##########
# #
# #
# #
# #
# #
# #
# #
##
#
Hollow Upper Triangular (left):
##########
# #
# #
# #
# #
# #
# #
# #
##
#
Solid Upper triangle (right):
##########
#########
########
#######
######
#####
####
###
##
#
Solid Upper triangle (left):
##########
#########
########
#######
######
#####
####
###
##
#
Hollow Lower Triangle (left):
#
##
# #
# #
# #
# #
# #
# #
# #
##########
Hollow Lower Triangle (right):
#
##
# #
# #
# #
# #
# #
# #
# #
##########
Solid lower triangle (left):
#
##
###
####
#####
######
#######
########
#########
##########
Solid lower triangle (right):
#
##
###
####
#####
######
#######
########
#########
##########
Hollow Diamond:
#
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
# #
#
Solid Diamond: (figure is somewhat wrong)
#
###
#####
#######
#########
###########
#############
###############
#################
###################
#####################
###################
#################
###############
#############
###########
#########
#######
#####
###
#
public static void Main (string[] args) {
Rectangle ();
System.out.println ("=============");
Krectangle ();
System.out.println ("=============");
Triangle ();
System.out.println ("=============");
Triangleleft ();
System.out.println ("=============");
Trianglesright ();
System.out.println ("=============");
Trianglesleft ();
System.out.println ("=============");
Trianglekleft ();
System.out.println ("=============");
Trianglekright ();
System.out.println ("=============");
Trianglesxleft ();
System.out.println ("=============");
Trianglesxbottom ();
System.out.println ("=============");
Rhombusk ();
System.out.println ("=============");
Rhombuss ();
}
/*
* Rectangle
*/
public static void Rectangle () {
for (int i = 0; i < 5; i++) {
for (int j = 0; J < J + +) {
if (i>=1&&i<=3&&j>0&&j<9)
if (j>0&&j<9)
{
System.out.print ("");
Continue
}
System.out.print ("*");
Continue
}
System.out.println ("");
}
}
/*
* Filled Rectangle:
*/
public static void Krectangle () {
for (int i=0;i<5;i++) {
for (int j=0;j<10;j++) {
System.out.print ("#");
}
System.out.println ("");
}
}
public static void triangle () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (i==j| | j==9| | i==0) {
System.out.print ("#");
}
else{
System.out.print ("");
}
}
System.out.println ("");
}
}
public static void Triangleleft () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (i+j==9| | j==0| | i==0) {
System.out.print ("#");
}
else{
System.out.print ("");
}
}
System.out.println ("");
}
}
public static void Trianglesright () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (j<i) {
System.out.print ("");
}
else {
System.out.print ("#");
}
}
System.out.println ("");
}
}
public static void Trianglesleft () {
for (int i=0;i<10;i++) {
for (int j=0;j<10-(i+1); j + +) {
System.out.print ("#");
}
System.out.println ("");
}
}
public static void Trianglekleft () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (j==0| | i==j| | i==9) {
System.out.print ("#");
}
else{
System.out.print ("");
}
}
System.out.println ("");
}
}
public static void Trianglekright () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (j==9| | (i+j) ==9| | i==9) {
System.out.print ("#");
}
else{
System.out.print ("");
}
}
System.out.println ("");
}
}
public static void Trianglesxleft () {
for (int i=0;i<10;i++) {
for (int j=0;j<i;j++) {
System.out.print ("#");
}
System.out.println ("");
}
}
public static void Trianglesxbottom () {
for (int i=0;i<10;i++) {
for (int j=0;j<10;j++) {
if (i+j<9) {
System.out.print ("");
}
else{
System.out.print ("#");
}
}
System.out.println ("");
}
}
public static void Rhombusk () {
for (int i=0;i<10;i++) {
for (int j=0;j<20;j++) {
if (i+j==10| | J==10+i)
{
System.out.print ("*");
}
else{
System.out.print ("");
}
}
System.out.println ("");
}
for (int k=0;k<11;k++) {
for (int l=0;l<21;l++) {
/*if (k==0) {
Continue
}*/
if (l==k| | (k+l) ==20) {
System.out.print ("*");
}
else{
System.out.print ("");
}
}system.out.println ("");
}
}
public static void Rhombuss () {
for (int i=0;i<10;i++) {
for (int j=0;j<10-i;j++) {
System.out.print ("");
}
for (int k=0;k< (i*2) +1;k++) {
System.out.print ("#");
}
System.out.println ("");
}
for (int x=0;x<11;x++) {
for (int y=0;y<x;y++) {
System.out.print ("");
}
for (int z=0;z<2* (10-x) +1;z++) {
System.out.print ("#");
}
System.out.println ("");
}
}
Three, design a program, the output is as follows: [Class name is: Factorial.java]
/*******************************************************
1!=1
2!=2
3!=6
4!=24
5!=120
6!=720
7!=5040
8!=40320
9!=362880
10!=3628800
Output end result:
1!+2!+3!+4!+5!+6!+7!+8!+9!+10!=4037913
public static void Main (string[] args) {
factorial ();
}
static void factorial () {
int su=1;
String s= "";
int sum=0;
for (int j=1;j<11;j++) {
if (j==10) {
s=s+j+ "!=";
}
else{
s=s+j+ "!+";
}
Su=su*j;
Sum=sum+su;
System.out.println (j+ "!=" +SU);
}
System.out.println ("Output end result:");
System.out.println (s+sum);
}
Four, the magic number [Amazingnumber] is as follows: [Three methods are written in a class]
* Magical digital <br/>
* 1*8+1= 9
* 12*8+2=
* 123*8+3= 987
* 1234*8+4= 9876
* 12345*8+5= 98765
* 123456*8+6= 987654
* 1234567*8+7= 9876543
* 12345678*8 +8= 98765432
* 123456789*8+9= 987654321
* magic number <br/>
*
*