首页 > 其他分享 >Method Demo07

Method Demo07

时间:2023-10-25 16:46:26浏览次数:42  
标签:int System Method static println Demo07 public out

package com.chen.method;

import java.util.Scanner;
public class Demo07 {
public static void main(String[] args) {
for(int i = 0;i>=0;i++){
Scanner scanner = new Scanner(System.in);
System.out.println("请输入两个数字与算数符号,各个之间加空格:");
int a=scanner.nextInt();
String suanfa= scanner.next();
int b=scanner.nextInt();
switch (suanfa) {
case "+" :
System.out.println(a+"+"+b+"="+add(a,b));
break;
case "-" :
System.out.println(a+"-"+b+"="+del(a,b));
break;
case "*" :
System.out.println(a+"*"+b+"="+cheng(a,b));
break;
case "/" :
System.out.println(a+"/"+b+"="+chu(a,b));
break;
}
}
}
public static int add(int a,int b){
return a+b;
}
public static int del(int a,int b){
return a-b;
}
public static int cheng(int a,int b){
return a*b;
}
public static int chu(int a,int b){
return a/b;
}
}

标签:int,System,Method,static,println,Demo07,public,out
From: https://www.cnblogs.com/jingyichenloveningning/p/17787562.html

相关文章

  • Method Dmeo06
    packagecom.chen.method;importjava.util.Scanner;publicclassDemo06{publicstaticvoidmain(String[]args){inti=1;while(i>0){//输入Scannerscanner=newScanner(System.in);//值1doublenum1=s......
  • Method Dmeo05
    packagecom.chen.method;publicclassDemo05{publicstaticvoidmain(String[]args){Demo05demo05=newDemo05();System.out.println(f(5));}publicstaticintf(inti){if(i==1){return1;......
  • Method Demo02
    packagecom.chen.method;publicclassDemo02{publicstaticvoidmain(String[]args){doublesum=sum(1.0,1.0);System.out.println(sum);}//比大小publicstaticdoublesum(doublea,doubleb){doubleresult=0;......
  • Method Demo01
    packagecom.chen.method;publicclassDemo01{//main方法publicstaticvoidmain(String[]args){intsum=add(1,2,3);System.out.println(sum);//test();}//加法publicstaticintadd(inta,intb){returna+......
  • 【PowerShell】Invoke-WebRequest和Invoke-RestMethod
    ##PublicfreeRestfulAPIURL ##https://documenter.getpostman.com/view/8854915/Szf7znEe#intro#Example01#--------------------------------------------------------------$url="https://cat-fact.herokuapp.com/facts/"$r=Invoke-WebReques......
  • IDEA 出现 Cannot resolve method getParameter() in JSP 解决方法
    原链接java-CannotresolvemethodgetParameter()inJSP-StackOverflowIDEA中出现下图情况,版本IDEA2022.2.3。此方法大概率可用,如果帮到你请点个赞吧~  1.我们右键当前项目,选择进入"OpenModuleSettings",如下图2.进入下图界面后,点击下图加号弹出二级菜单,在通......
  • [914] In Python's datetime library, you can format dates using the strftime() me
    InPython'sdatetimelibrary,youcanformatdatesusingthestrftime()method.Thismethodallowsyoutocreateaformattedstringrepresentationofadatetimeobject,specifyingtheformatyouwant.Here'showyoucanformatadateusingstrft......
  • Program does not contain a static 'Main' method suitable for an entry point
    http://www.kangry.net/blog/?article_id=391&type=article修改办法,对着项目右键-》属性-》application-》outputtype设为ClassLibrary即可。  ......
  • [905] The replace() method in Pandas
    InPandas,thereplace()methodisusedtoreplacevaluesinaDataFrameorSeries.Youcanusethismethodtoreplaceoneormorespecifiedvalueswithothervalues.Here'showyoucanuseit:Syntax:DataFrame.replace(to_replace,value,inplace=Fal......
  • operator Demo07
    packagecom.chen.operator;publicclassDemo07{publicstaticvoidmain(String[]args){inta=10;intb=20;a+=b;//a=a+ba-=b;//a=a-bSystem.out.println(a);//字符串链接符+,String......