




已阅读5页,还剩11页未读, 继续免费阅读
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
package my.p4;import java.util.Scanner;public class FractorialTest /* * param args */public static void main(String args) Scanner input = new Scanner(System.in);System.out.println(Input an integer:n);int inputnumber = input.nextInt();/*GetFactorial f = new GetFactorial();f.setInputn(inputnumber);int nn = f.getInputn();int factor = f.factoriall(nn);System.out.printf(The factorial of %d is %dnnn, nn, factor);*/double sum = 0;int counter = 0;int nn = 0;int n = 0;while (counter inputnumber) GetFactorial ff = new GetFactorial();ff.setInputn(+counter);nn = ff.getInputn();System.out.printf(Compute the factorial of number %d.n,ff.getInputn();n = ff.factoriall(nn);sum += (double)1/n; /*very important System.out.printf(The factorial of %d is %dn, nn, n);System.out.printf(nThe exponential approximation is: %.4f nn, sum);/System.out.printf(nIts exponential approximation is: %f , sum);package my.p4;public class GetFactorial private int counter;private int factorial;private int inputn;public GetFactorial() this.counter = 0;this.factorial = 1;this.inputn = 0;public int getInputn() return inputn;public void setInputn(int input) this.inputn = input;public int factoriall(int input) input = getInputn();while (+counter = input) factorial *= counter;return factorial;/P139_4$24package my.p4;public class Mystery2 public static void main(String args) int count = 1;while (count = 1) column = 1;/ P139_4$26while (column = 10) System.out.print(row % 2 = 1 ? );+column; / end while-row;System.out.println(); / end while / end main / end class Mystery2package my.p4;public class P135_4$5 /* * param args */public static void main(String args) / TODO Auto-generated method stubint x = 1;int sum = 0;sum += 1;System.out.printf(The sum is: %d, sum);/ sum 110int sum1 = 0,y=1;/*int y = 1;while (y = 10)sum1 += y;+y;/int sum, x, sum1;*/+sum1;System.out.printf(nThe sum is: %d, sum1);package my.p4;import java.util.Scanner;public class P136_4$17 public static void main(String args) Scanner input = new Scanner(System.in);int tanks = 0;double even;int gallons = 0;int miles = 0;int increasedpetrol;int increasedmiles; System.out.print(start the loop tangks = .n);while ( +tanks = 3 ) System.out.printf(tanks = %dn, tanks);System.out.print(input the petrol cost:);increasedpetrol = input.nextInt();gallons = gallons + increasedpetrol;System.out.print(input the miles past:);increasedmiles = input.nextInt();miles = miles + increasedmiles;even = (double) gallons / miles;System.out.printf(The total number of tank of petrol cost is %d, which means that %.2f gallon petrol were cost per mile.,tanks, even);package my.p4;import java.util.Scanner;public class P136_4$18 /* 注意花括号再多行中的作用,理解static关键字的含义 */public static void main(String args) Scanner input = new Scanner(System.in);int sn;int remainder;int total;int income;System.out.print(nInput the serial number:);sn = input.nextInt();if (sn = 1)System.out.println(nInput your income of this month:);income = input.nextInt();remainder = 1000;total = remainder + income;System.out.printf(the remainder of this month is %d,nAdd the income %d,nThe total of %d is %d,remainder, income, sn, total);System.out.print(ncheck out the CREDIT LIMITED.);checkCreditLmited(total);if (sn = 2)remainder = 600;System.out.println(nInput your income of this month:);income = input.nextInt();total = remainder + income;System.out.printf(the remainder of this month is %d,nAdd the income %d,nThe total of %d is %d,remainder, income, sn, total);System.out.print(ncheck out the CREDIT LIMITED.);checkCreditLmited(total);if (sn = 3)remainder = 500;System.out.println(nInput your income of this month:);income = input.nextInt();total = remainder + income;System.out.printf(the remainder of this month is %d,nAdd the income %d,nThe total of %d is %d,remainder, income, sn, total);System.out.print(ncheck out the CREDIT LIMITED.);checkCreditLmited(total); /public static void checkCreditLmited(int total) if (total = 500)System.out.print(n*YOU still have CREDIT*);System.out.printf(nYour credit is: %d, total - 500);package my.p4;import java.util.Scanner;public class P138_4$19 public static void main(String args) / TODO Auto-generated method stub Scanner input = new Scanner(System.in); int salarybase = 200;int salesamount1, salesamount2, salesamount3, salesamount4;double saleprice1 = 239.99, saleprice2 = 129.75, saleprice3 = 99.95, saleprice4 = 350.89;double totalsalary;System.out.print(Input the sales amount of FOUR types of products of a saler nn);System.out.print(input the sales amount of the first type of products of a saler: n);salesamount1 = input.nextInt();System.out.print(input the sales amount of the second type of products of a saler: n);salesamount2 = input.nextInt();System.out.print(input the sales amount of the third type of products of a saler: n);salesamount3 = input.nextInt();System.out.print(input the sales amount of the fourth type of products of a saler: n);salesamount4 = input.nextInt();System.out.print(nnnComputing his total salary.nnn);totalsalary = salarybase + (salesamount1 * saleprice1 +salesamount2 * saleprice2 + salesamount3 * saleprice3 + salesamount4 * saleprice4) * 0.09;System.out.printf(nThe total salary is %.2f, totalsalary);package my.p4;import java.util.Scanner;public class P139_4$20 /* 注意print类型问题 */public static void main(String args) / TODO Auto-generated method stubScanner input = new Scanner(System.in);String name = null, nameinput;int workinghour = 0;int counter = 1;double salary = 0;int salaryperhour = 10;while (counter 40) salary = (workinghour - 40) * salaryperhour / 2 + 40* salaryperhour;if (workinghour = 40) salary = workinghour * salaryperhour;System.out.printf(nnThe %dth worker %s working %d hours per week.nAnd his salary is %.2fnnn,counter, name, workinghour, salary);+counter;package my.p4;import java.util.Scanner;public class P139_4$21 /* * param args */public static void main(String args) / TODO Auto-generated method stubScanner input = new Scanner(System.in);int counter = 0;int number; / inputint largest = 0;int maxcounter = 0;while (+counter largest) largest = number;System.out.printf(The largest number is %d, largest);if (number = largest) maxcounter = counter;if (counter = 10)System.out.printf(the largest one of the ten number is %d,largest);System.out.printf(nthe %dth nuber is the largest, maxcounter);package my.p4;public class P139_4$22 public static void main(String args) / TODO Auto-generated method stubint counter = 0;System.out.print(Nt10*Nt100*Nt1000*Ntn);while (+counter = 5) System.out.printf(n%dt%dt%dt%dt, counter, 10 * counter,100 * counter, 1000 * counter);package my.p4;import java.util.Scanner;public class P139_4$23 /* * param args */public static void main(String args) / TODO Auto-generated method stubScanner input = new Scanner(System.in);int counter = 0;int number; / inputint largest = 0;int secondlargest = 0;int maxcounter = 0;int secondmaxcounter = 0;while (+counter largest) secondlargest = largest;largest = number;System.out.print(*);System.out.printf(nThe largest number is %d, largest);System.out.printf(nThe second largest number is %d, secondlargest);System.out.print(n*n);if (number = largest) maxcounter = counter;/*while (secondlargest = largest) secondmaxcounter = counter;*/if (number secondlargest)secondlargest = number;secondmaxcounter = counter;System.out.print(*);System.out.printf(nThe largest number is %d, largest);System.out.printf(nThe second largest number is %d, secondlargest);System.out.print(n*n);if (number 8)System.out.println( Raise Tuition);*/package my.p4;import java.util.Scanner;public class P141_4$29 /* * param args */public static void main(String args) Scanner input = new Scanner(System.in);int sidelength;/ int counter = 1;int row = 0;int column = 1;System.out.print(Input the sidelength of the
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025国家教育行政学院招聘9人(非事业编)考试参考试题及答案解析
- 社区红色议事会会议记录范文大全
- 防艾禁毒进入社区三下乡活动简要计划
- 2025西安雁塔区等驾坡社区卫生服务中心招聘(3人)备考练习试题及答案解析
- 输血考试培训试题附答案
- 化学实验室安全知识培训考核试题库(含答案)
- 护士基础护理+院感考试试题(附答案)
- 社会工作师考试社会工作实务(中级)试题及解答参考(2025年)
- 2025海南省老年病医院招聘员额制工作人员63人(第1号)备考练习试题及答案解析
- 2025年河北张家口沽源县临时公益性岗位招聘备考练习试题及答案解析
- 华北理工选矿厂设计教案第16-17讲 辅助设备和设施的选择与计算
- 电气控制及PLC应用-定时器、计数器指令介绍
- 大学生劳动教育PPT新时代大学生劳动教育教程全套完整教学课件
- 云南小粒种咖啡栽培技术
- JJF 1071-2010国家计量校准规范编写规则
- GB/T 27548-2011移动式升降工作平台安全规则、检查、维护和操作
- 饲料卫生标准解读x自动保存的
- GB/T 22166-2008非校准起重圆环链和吊链使用和维护
- GB/T 12236-2008石油、化工及相关工业用的钢制旋启式止回阀
- 《应用文写作与文献检索》课程教学大纲
- 鲫鱼解剖试验课件
评论
0/150
提交评论