移动应用开发做一个计算器(安卓制作一个计算器)

网友投稿 1520 2023-01-16

本篇文章给大家谈谈移动应用开发做一个计算器,以及安卓制作一个计算器对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。 今天给各位分享移动应用开发做一个计算器的知识,其中也会对安卓制作一个计算器进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

小白求教:想自己编出一个安卓的计算器app要学什么

刚入门有点迷惘很正常的,不要灰心,按部就班来,学习Android 主要分为2大部分,要是只想看如何做计算器app可以直接跳到最后

1、Java基础知识

很多朋友一上手就开始学习Android,似乎太着急了一些。Android应用程序开发是以Java语言为基础的,所以没有扎实的Java基础知识,只是机械的照抄别人的代码,是没有任何意义的。万丈高楼平地而起,Java就是筑起高楼的每一块砖头。那么Java学到什么程度才算是过关呢?我个人认为至少要掌握以下两个方面的内容:
a)(必学)Java基础语法:推荐《java核心编程卷1》,像《Think in Java》这种砖头书可以当做字典查阅不太适合入门。基础语法这部分内容没有讨价还价的余地,必须烂熟于胸。至于具体的学习方法,可以看书或者是看视频,但是关键是要多加练习,无论是书上的练习还是视频里面的练习,都需要仔仔细细的完成;

b)(可选)设计模式:由于在Android系统的框架层当中,使用了大量的设计模式,如果没有这个方面的知识,对于Android的理解就会大打折扣。设计模式的种类非常之多,一个一个的全部掌握,是不现实的,必须首先掌握面向对象的基础设计原则,有了这些基础原则的支持,就可以举一反三。这部分内容可以在《Effective Java》。

具体的点包括以下

1).Java基本数据类型与表达式,分支循环。

2).String和StringBuffer的使用、正则表达式。

3).面向对象的抽象,封装,继承,多态,类与对象,对象初始化和回收;构造函数、this关键字、方法和方法的参数传递过程、static关键字、内部类。

4).对象实例化过程、方法的覆盖、final关键字、抽象类、接口、继承的优点和缺点剖析;对象的多态性:子类和父类之间的转换、抽象类和接口在多态中的应用、多态带来的好处。

5).Java异常处理,异常的机制原理。

6).常用的设计模式:Singleton、Template、Strategy模式。

7).JavaAPI介绍:种基本数据类型包装类,System和Runtime类,Date和DateFomat类等。

8).Java集合介绍:Collection、Set、List、ArrayList、LinkedList、Hashset、Map、HashMap、Iterator等常用集合类API。

9).JavaI/O输入输出流:File和FileRandomAccess类,字节流InputStream和OutputStream,字符流Reader和Writer,以及相应实现类,IO性能分析,字节和字符的转化流,包装流的概念,以及常用包装类,计算机编码。

10).Java高级特性:反射和泛型。

11).多线程原理:如何在程序中创建多线程(Thread、Runnable),线程安全问题,线程的同步,线程之间的通讯、死锁。

2、Android部分

入门书籍推荐郭霖大神的《第一行代码》通过打怪升级方式一步步了解Android世界

重点需要掌握:

UI布局 网页链接

四大组件网页链接

数据存储技术

一些常用的Android 可以参考 网页链接

3、针对你的这个计算需求

基本java语法,UI布局、Activity使用 这些技术点 就够了 最后给个相关的计算机实现的参考链接 网页链接  祝你早日入门android

用C语言设计一个简单计算器

#include<stdio.h 
void add(int a,int b,int c) 

 c=a+b; 
 printf("%d\t",c); 
 printf("\n"); 

void minus(int a,int b,int c) 

 c=a-b; 
 printf("%d\t",c); 
 printf("\n"); 

void multiplication(int a,int b,int c) 

 c=a*b; 
 printf("%d\t",c); 
 printf("\n"); 

void div(int a,int b,int c) 

 c=(float)a/(float)b; 
 printf("%f\t",c); 
 printf("\n"); 

main() 

 int a,b,c; 
 char p; 
 puts("input A:\n"); 
 scanf("%d",a); 
 puts("input B:\n"); 
 scanf("%d",b); 
 puts("input operation:\n"); 
 getchar(); 
 p=getchar(); 
 if(p=='+') add(a,b,c);else 
  if(p=='-') minus(a,b,c);else 
   if(p=='*') multiplication(a,b,c);else 
    if(p=='/') div(a,b,c);else 
     puts("没有注册这个运算符号\n"); 
}

以上是设计的一个简易计算器。可以进行相应的加减乘除。

简介:

C语言是一种计算机程序设计语言移动应用开发做一个计算器,它既具有高级语言的特点移动应用开发做一个计算器,又具有汇编语言的特点。它由美国贝尔研究所的D.M.Ritchie于1972年推出,1978年后,C语言已先后被移植到大、中、小及微型机上,它可以作为工作系统设计语言,编写系统应用程序,也可以作为应用程序设计语言,编写不依赖计算机硬件的应用程序。它的应用范围广泛,具备很强的数据处理能力,不仅仅是在软件开发上,而且各类科研都需要用到C语言,适于编写系统软件,三维,二维图形和动画,具体应用比如单片机以及嵌入式系统开发。

编写程序,开发一个简单的计算器,输入两个数后可以进行加减乘除等运算

界面设计的代码我就不写了,我在这里描述一下:
放置两个TextBox,分别命名为txtP1,txtP2
放置一个TextBox,命名为txtResult
放置一个ComboBox,命名为drpOperation,在Items属性里面添加(Collection),分别为+,-,*,/
放置一个Button,命名为btnCalculate
双击btnCalculate
代码如下:
private void btnCalculate_Click(object sender, EventArgs e)
{
double p1=Convert.ToDouble(txtP1.Text);//从txtP1中获取参数p1
double p2=Convert.ToDouble(txtP2.Text);//从txtP1中获取参数p1
double result;//定义运算结果
string Operation=drpOperation.SelectedItem.Text;//获取运算符
switch(Operation)
{
case "+":result=p1+p2;break;
case "-":result=p1-p2;break;
case "*":result=p1*p2;break;
case "/":result=p1/p2;break;
}//这里判断从ComboBox获取的符号,以求进行相应的运算
txtResult.Text=result.ToString();//显示运算结果
}

开发一个简易的计算器APP程序 Android源代码

下面是效果展示:

复制代码代码如下:


<?xml version="1.0" encoding="utf-8"?
<LinearLayout xmlns:android="s/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<TextView
android:id="@+id/tvResult"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:height="50dp"
android:text="@string/tvResult"
/
</LinearLayout
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/btnBackspace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:layout_marginLeft="10dp"
android:text="@string/btnbackspace"/
<Button
android:id="@+id/btnCE"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="150dp"
android:text="@string/btnCE"/
</LinearLayout
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/btn7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn7"/
<Button
android:id="@+id/btn8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn8"/
<Button
android:id="@+id/btn9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn9"/
<Button
android:id="@+id/btnDiv"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnDiv"/
</LinearLayout
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/btn4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn4"/
<Button
android:id="@+id/btn5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn5"/
<Button
android:id="@+id/btn6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn6"/
<Button
android:id="@+id/btnMul"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnMul"/
</LinearLayout
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/btn1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn1"/
<Button
android:id="@+id/btn2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn2"/
<Button
android:id="@+id/btn3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btn3"/
<Button
android:id="@+id/btnAdd"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnAdd"/
</LinearLayout
<LinearLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
<Button
android:id="@+id/btn0"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:width="75dp"
android:text="@string/btn0"/
<Button
android:id="@+id/btnC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnC"/
<Button
android:id="@+id/btnEqu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnEqu"/
<Button
android:id="@+id/btnSub"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:width="75dp"
android:text="@string/btnSub"/
</LinearLayout
</LinearLayout

复制代码代码如下:


package com.example.week2;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;
public class MainActivity extends Activity  implements OnClickListener{
//声明一些控件
Button btn0=null;
Button btn1=null;
Button btn2=null;
Button btn3=null;
Button btn4=null;
Button btn5=null;
Button btn6=null;
Button btn7=null;
Button btn8=null;
Button btn9=null;
Button btnBackspace=null;
Button btnCE=null;
Button btnC=null;
Button btnAdd=null;
Button btnSub=null;
Button btnMul=null;
Button btnDiv=null;
Button btnEqu=null;
TextView tvResult=null;
//声明两个参数。接收tvResult前后的值
double num1=0,num2=0;
double Result=0;//计算结果
int op=0;//判断操作数,
boolean isClickEqu=false;//判断是否按了“=”按钮
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//从布局文件中获取控件,
btn0=(Button)findViewById(R.id.btn0);
btn1=(Button)findViewById(R.id.btn1);
btn2=(Button)findViewById(R.id.btn2);
btn3=(Button)findViewById(R.id.btn3);
btn4=(Button)findViewById(R.id.btn4);
btn5=(Button)findViewById(R.id.btn5);
btn6=(Button)findViewById(R.id.btn6);
btn7=(Button)findViewById(R.id.btn7);
btn8=(Button)findViewById(R.id.btn8);
btn9=(Button)findViewById(R.id.btn9);
btnBackspace=(Button)findViewById(R.id.btnBackspace);
btnCE=(Button)findViewById(R.id.btnCE);
btnC=(Button)findViewById(R.id.btnC);
btnEqu=(Button)findViewById(R.id.btnEqu);
btnAdd=(Button)findViewById(R.id.btnAdd);
btnSub=(Button)findViewById(R.id.btnSub);
btnMul=(Button)findViewById(R.id.btnMul);
btnDiv=(Button)findViewById(R.id.btnDiv);
tvResult=(TextView)findViewById(R.id.tvResult);
//添加监听\
btnBackspace.setOnClickListener(this);
btnCE.setOnClickListener(this);
btn0.setOnClickListener(this);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
btn6.setOnClickListener(this);
btn7.setOnClickListener(this);
btn8.setOnClickListener(this);
btn9.setOnClickListener(this);
btnAdd.setOnClickListener(this);
btnSub.setOnClickListener(this);
btnMul.setOnClickListener(this);
btnDiv.setOnClickListener(this);
btnEqu.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
//btnBackspace和CE--------------------
case R.id.btnBackspace:
String myStr=tvResult.getText().toString();
try {
tvResult.setText(myStr.substring(0, myStr.length()-1));
} catch (Exception e) {
tvResult.setText("");
}
break;
case R.id.btnCE:
tvResult.setText(null);
break;
//btn0--9---------------------------
case R.id.btn0:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString=tvResult.getText().toString();
myString+="0";
tvResult.setText(myString);
break;
case R.id.btn1:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString1=tvResult.getText().toString();
myString1+="1";
tvResult.setText(myString1);
break;
case R.id.btn2:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString2=tvResult.getText().toString();
myString2+="2";
tvResult.setText(myString2);
break;
case R.id.btn3:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString3=tvResult.getText().toString();
myString3+="3";
tvResult.setText(myString3);
break;
cas

C语言程序设计,做一个简单计算器。

1、首先,打开Vs 2010,如图。

2、找到左上角的新建并点击,给文件为简单计算器,单击确定。

3、点击下一步,注意勾选空项目,点击下一步,点击完成。

4、点击左侧的源文件,右击选择“添加—项目”,选择C++文件,命名为简单计算器,因为是C程序,注意后缀名要加上.c,点击确定完成文件新建工作。

5、输入以下代码,好了,一个简单的计算器便做好了

关于移动应用开发做一个计算器和安卓制作一个计算器的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。 移动应用开发做一个计算器的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于安卓制作一个计算器、移动应用开发做一个计算器的信息别忘了在本站进行查找喔。

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:金融小程序场景(金信融微信小程序是什么)
下一篇:微信做的是小程序生态(微信做的是小程序生态吗)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~