「java大佬」Java大佬业务代码

博主:adminadmin 2022-12-28 18:27:11 54

本篇文章给大家谈谈java大佬,以及Java大佬业务代码对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。

本文目录一览:

java开发的大佬们,脑子宕机在这里卡住了 求救

public class MyShopping {

public static void main(String[] args) {

boolean isRight = true; //用于判断用户是否输入正确初始为正确

Scanner input = new Scanner(System.in);

System.out.println("欢迎使用MyShopping管理系统");

System.out.println("********************************************");

System.out.println("1.客户信息管理");

System.out.println("2.购物结算");

System.out.println("3.真情回馈");

System.out.println("4.注销");

System.out.println("********************************************\n");

System.out.println("请选择,输入数字:");

int nextInt = input.nextInt();

do {

if (!(nextInt = 1 nextInt = 4)) { //判断是否为数字并且在1-4之间

System.out.println("输入错误请重新输入!");

isRight = false;

System.out.println("请选择,输入数字:");

nextInt = input.nextInt();

} else {

isRight = true;

switch (nextInt) { //根据输入的正确条件

case 1:

System.out.println("执行客户信息管理");

break;

case 2:

System.out.println("执行购物结算");

break;

case 3:

System.out.println("执行真情回馈");

break;

case 4:

System.out.println("执行注销");

break;

}

}

} while (!isRight); //判断条件 如果输入错误则重新执行语句

System.out.println("程序结束");//循环体执行完毕后提醒关闭程序

}

}

求JAVA大佬救命

你这题目本身就有一定的问题,如果开根号之后的值是个整数呢?就是开根号之后的值的长度小于6怎么办?是补0还是直接输出?

demo(仅供参考):

import java.util.Scanner;

public class Text {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int a = sc.nextInt();

        double b = sc.nextDouble();

        double sum = a + b;

        // 输出两个数的和

        System.out.println(sum);

        double sqrt = Math.sqrt(sum);

        // 输出两个数的和的开方数

        System.out.println(sqrt);

        String str = String.valueOf(sqrt);

        int len = str.length()  6 ? str.length() : 6;

        char[] ars = new char[len];

        System.arraycopy(str.toCharArray(), 0, ars, 0, len);

        // 输出两个数的和的开方数的前6位,如果少于6位,不补0

        System.out.println(String.valueOf(ars));

    }

}

输入:

2

3.15

输出:

5.15

2.2693611435820435

2.2693

输入:

2

7.0

输出:

9.0

3.0

3.0

求java大佬解决

import java.util.Scanner;

public class test1{

public static void main(String [] args){

Scanner cin=new Scanner(System.in);

int n=cin.nextInt();

int []a=new int[n];

int len=0;

int max1=0;

for(int i=0;in;i++){//输入n个字符串(非end,转化为int),输入结束

String num=cin.next();

if(num.compareTo("end")==0) {//输入num为end,输入提前结束

break;

}

else {

a[len] = Integer.valueOf(num, 10);//不是end的字符串转换为int,存入数组a中

max1=Math.max(a[len],max1);//记录最大值

len++;//数组长度加一

}

}

System.out.print("数组中元素为: [");

for(int i=0;in;i++){

if(i!=n-1)

System.out.print(a[i]+",");

else

System.out.print(a[i]);

}

System.out.print("],最大值为"+max1);

}

}

java哥什么梗

指的虚拟主播Luxiem组合中Luca。

他在一次直播时,疑似不小心喊出了前世的名字“java”,因此网友们都喊他“java哥”。

求java大佬帮忙

import java.util.ArrayList;

import java.util.Arrays;

import java.util.List;

public class Recipe {

private String name; //菜谱名称

private String style; //菜系 如:川菜、湘菜等

private int time; //烹饪时长 分钟

private String[] food; //食材

private String[] step; //操作步骤

public Recipe() {

}

public Recipe(String name, String style, int time, String[] food, String[] step) {

this.name = name;

this.style = style;

this.time = time;

this.food = food;

this.step = step;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

public String getStyle() {

return style;

}

public void setStyle(String style) {

this.style = style;

}

public int getTime() {

return time;

}

public void setTime(int time) {

this.time = time;

}

public String[] getFood() {

return food;

}

public void setFood(String[] food) {

this.food = food;

}

public String[] getStep() {

return step;

}

public void setStep(String[] step) {

this.step = step;

}

@Override

public String toString() {

String foods="";

for (String f : food) {

foods+=f+" ";

}

String steps="";

for (int i = 0; i step.length; i++) {

steps += (i+1)+"."+step[i];

if(i!=step.length-1){

steps+=";";

}

}

return "菜谱名称:" + name +

"\n菜系:" + style +

"\n时长:" + time +

"\n所需食材:" + foods +

"\n操作步骤:" + steps;

}

public static void print(Recipe[] recipes){

for (Recipe recipe : recipes) {

System.out.println(recipe);

}

}

public static Recipe[] searchRecipesContainName(Recipe[] recipes, String name){

ListRecipe list=new ArrayListRecipe();

for (Recipe recipe : recipes) {

if(recipe.getName().contains(name)){

list.add(recipe);

}

}

return list.toArray(new Recipe[list.size()]);

}

public static Recipe[] searchRecipes(Recipe[] recipes, String style){

ListRecipe list=new ArrayListRecipe();

for (Recipe recipe : recipes) {

if(recipe.getStyle().equals(style)){

list.add(recipe);

}

}

return list.toArray(new Recipe[list.size()]);

}

public static Recipe[] searchRecipeLessThan(Recipe[] recipes, int time){

ListRecipe list=new ArrayListRecipe();

for (Recipe recipe : recipes) {

if(recipe.getTime()time){

list.add(recipe);

}

}

return list.toArray(new Recipe[list.size()]);

}

public static Recipe[] searchRecipeContainsFood(Recipe[] recipes, String food){

ListRecipe list=new ArrayListRecipe();

for (Recipe recipe : recipes) {

for (String s : recipe.getFood()) {

if(s.equals(food)){

list.add(recipe);

}

}

}

return list.toArray(new Recipe[list.size()]);

}

public static void main(String[] args) {

//存储5个菜谱的信息

Recipe[] recipes=new Recipe[5];

recipes[0]=new Recipe("酱牛肉","家常菜",120,

new String[]{

"牛腱子",

"黄豆酱油",

"黄酒",

"冰糖"

},

new String[]{

"准备好主要食材",

"加入食材慢炖两至三小时"

});

recipes[1]=new Recipe("红烧牛肉","家常菜",120,

new String[]{

"牛腩",

"牛筋",

"生抽",

"冰糖"

},new String[]{

"准备好主要食材",

"加入食材慢炖两至三小时"

});

recipes[2]=new Recipe("小鸡炖蘑菇","湘菜",100,

new String[]{

"小鸡",

"蘑菇"

},

new String[]{

"准备好主要食材",

"加入食材慢炖两至三小时"

});

recipes[3]=new Recipe("地三鲜","川菜",25,

new String[]{

"茄子",

"辣椒"

},

new String[]{

"准备好主要食材",

"加入食材慢炖"

});

recipes[4]=new Recipe("西红柿","湘菜",20,

new String[]{

"西红柿",

"味达美酱油"

},

new String[]{

"准备好主要食材",

"加入食材慢炖"

});

System.out.println("找到所有名称中包含牛肉的菜谱:");

Recipe[] result_1 = searchRecipesContainName(recipes, "牛肉");

print(result_1);

System.out.println("\n希望查找所有湘菜的菜谱:");

Recipe[] result_2=searchRecipes(recipes,"湘菜");

print(result_2);

System.out.println("\n查找烹饪时长小于30分钟的菜谱:");

Recipe[] result_3=searchRecipeLessThan(recipes,30);

print(result_3);

System.out.println("\n查找包含西红柿的菜谱:");

Recipe[] result_4=searchRecipeContainsFood(recipes,"西红柿");

print(result_4);

}

}

JAVA大佬这个咋执行的?

您好,您的这个代码猛然一看是好像的确是第一个循环完毕,再循环第二个,也就是第一行执行完毕之后,再执行第二行。但是仔细分析发现,您的这个代码是有问题的,第二行的c i , 由于i是定义在第一个循环中的,而且i是一个局部变量,所以第二个循环是拿不到i值的,也就是说这个程序编译是有问题的。

关于java大佬和Java大佬业务代码的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-12-28,除非注明,否则均为首码项目网原创文章,转载请注明出处。