【我不做人啦!Java!】1.变量、数据类型和运算符

本文详细探讨了Java编程中的基础概念,包括变量的使用、各种数据类型的介绍以及运算符的运用。在文章中,作者通过实例解释了如何计算Apple笔记本今年所占市场份额的增长情况。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

-----1-----

在这里插入图片描述

class MP3{
  public static void main(String[] args){
  String brand = "爱国者F928";
  double weight = 12.4;
  String type = "内置锂电池";
  int price = 499;
  System.out.println("品牌:"+brand);
   System.out.println("重量:"+weight);
    System.out.println("电池类型:"+type);
	 System.out.println("价格:"+price);
  }
}

-1-

-----2-----

在这里插入图片描述

2.1

class ex2_2_1{
public static void main(String[] args)
 {
   int days=46,a=7;
   int week=((days/a)+1);
   int day=(days%a);
   System.out.println("第46天是第"+week+"周");
   System.out.println("本周剩余"+day+"天");

   } 
}

-2.1-
2.2

class ex2_2_1
{
   public static void main(String[] args)
   {
      double radius=1.5;
	  double Area=0;
	  Area = (radius*radius)*3.14;
      System.out.println("圆的半径为:"+radius);
      System.out.println("圆的面积为:"+Area);
   }
}

在这里插入图片描述

-----3-----

在这里插入图片描述

import java.util.Scanner;
class Encryption{
	public static void main(String[] args) {
      Scanner input = new Scanner(System.in);
	  System.out.println("请输入要加密的整数");
	  int x = input.nextInt();
      int a = (int)((((x*10)+5)/2)+3.14159);
		System.out.println("加密结果是:"+a);
	}
}

在这里插入图片描述

-----4-----

去年Apple笔记本所占的市场份额是20,今年增长的市场份额是9.8%,求今年所占的份额?

class ex2_4 {
	public static void main(String[] args) {
        int a = 20;
		double b = 0.098;
		double c = a*(1+b);
		System.out.println(c);
	}
}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值