三九宝宝网宝宝教育教学论文

计算机编程java语言题目

02月22日 编辑 39baobao.com

[java线性表编程一定要用java语言]借用楼上的代码 import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; public class Test { public static void...+阅读

********************************** 新建类LuggageFee.java,代码如下: ******************************************************************** import java.util.Scanner; public class LuggageFee { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (true) { System.out.println("Please input the luggage weight: "); String in = sc.nextLine(); if (in.matches("[1-9]\\d*\\.\\d*|0\\.\\d*[1-9]\\d*|[1-9]\\d*")) { System.out.println("The " + in.trim() + " luggage fee is: " + getLuggageFee(Double.valueOf(in))); } else { System.out.println("Input error, please try again!"); } } } public static double getLuggageFee(double weight) { if (weight < 20) { return 0; } else if (weight < 40) { return (weight - 20) * 0.015; } else { return (weight - 20) * 0.015 + (weight - 40) * 2 * 0.015; } } } ******************************************************************** 运行结果如下: ******************************************************************** Please input the luggage weight: -3 Input error, please try again! Please input the luggage weight: 15 The 15 luggage fee is: 0.0 Please input the luggage weight: 25 The 25 luggage fee is: 0.075 Please input the luggage weight: 100 The 100 luggage fee is: 3.0 Please input the luggage weight:

以下为关联文档:

Java函数式编程语言是什么函数式编程语言的核心是它以处理数据的方式处理代码。这意味着函数应该是第一等级(First-class)的值,并且能够被赋值给变量,传递给函数等等。 事实上,很多函数式语言比这走得更远...

汇编语言编程计算问题;汇编语言编程;计算 S=1+2*3+3*4+4*5+……+N*(N+1),N由用户输入,将结果在屏幕显示;---------------------------ASSUME CS:CC, DS:QW;---------------------------QW SEGMENT M1...

计算机编程都有哪些语言?ALGOL (also under FORTRAN) Atlas Autocode ALGOL 60 Simula (see also Simula based languages) ALGOL 68 Burroughs Extended ALGOL ALGOL W Pascal Ada SPARK Turbo Pas...

计算机编程语言的语言分类为了克服机器语言难读、难编、难记和易出错的缺点,人们就用与代码指令实际含义相近的英文缩写词、字母和数字等符号来取代指令代码(如用ADD表示运算符号“+”的机器代码),于是就...

c语言编程题目void main() { int a[5],b[5]; int cnt=0,i,j,t; for(i=0;i<=4;i++) scanf("%d",&a[i]); for(i=0;i<=4;i++) if( (a[i]%10)%2==0 && (a[i]/10%10)%2==0 && (a[i]/100%10)%2==0...

c语言编程题目哈哈,纯暴力 结果为1098 #include <stdio.h> int main() { int a , b , c , d ; for( a = 1 ; a < 10 ; a++) for(b = 0 ; b < 10 ; b++) for( c = 0 ; c < 10 ; c++) for(d...

计算机c语言编程我编了这个程序,不涉及小时分钟的加减在十进制里这么转换。 小时就是(time2-time1)/100; 分钟就是后2位的相减,如果为负的话,向高位借位加60就行了 #include<stdio.h> main() {in...

计算机有哪些编程语言工业编程语言:A+|Ada|汇编语言|B|Brainfuck|C|C++|C++/CLI|Cg|COBOL|Eiffel|Erlang|FORTRAN|IronPython|Java|JRuby|Jython|LISP|Oberon|Objective-C|Ocaml|Pascal|Perl|Powe...

汇编语言编程题目 ???.model tiny .8086 CODE SEGMENT ASSUME CS:CODE,DS:CODE,ES:CODE ORG 100H START: JMP BEGIN ;you data buffer and defined parameter at here. SOURCE_WORD DW 00H COUNT...

推荐阅读
图文推荐