博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
结对2.03
阅读量:4839 次
发布时间:2019-06-11

本文共 4021 字,大约阅读时间需要 13 分钟。

#include<stdio.h>

#include <math.h>

#include<stdlib.h>

void fuli(){

    double F,P,I;

    int M,N;

    system("cls");

    printf("\t欢迎进入复利计算软件\n");

    printf("请输入存入本金:");

    scanf("%lf",&P);

    printf("请输入年利率:");

    scanf("%lf",&I);

    printf("请输入存入年限:");

    scanf("%d",&N);

    printf("请输入年复利次数:");

    scanf("%d",&M);

    printf("本金\t年利率\t存入年限\t年复利次数\n");

    printf("%.2lf\t%.2lf\t%d\t%d",P,I,N,M);

    I=pow((1+I/M),M)-1;

    F=P*pow((1+I),N);

    printf("\n输出复利终值结果:%.2lf\n",F);

}

 

void danli()

{

    

    double F,P,I;

    int N;

    system("cls");

    printf("\t欢迎进入单利计算软件\n");

    printf("请输入存入本金:");

    scanf("%lf",&P);

    printf("请输入年利率:");

    scanf("%lf",&I);

    printf("请输入存入年限:");

    scanf("%d",&N);

    printf("本金\t年利率\t存入年限 \n");

    printf("%.2lf\t%.2lf\t%d ",P,I,N);

    F=P+P*I*N;

    printf("\n输出复利终值结果:%.2lf\n",F);

}

 

void benjin()

{

    double F,P,I;

    int M,N;

    system("cls");

    printf("\t欢迎进入本金计算软件\n");

    printf("请输入终值:");

    scanf("%lf",&F);

    printf("请输入年利率:");

    scanf("%lf",&I);

    printf("请输入存入年限:");

    scanf("%d",&N);

    printf("请输入年复利次数:");

    scanf("%d",&M);

    printf("终值\t年利率\t存入年限\t年复利次数\n");

    printf("%.2lf\t%.2lf\t%d\t%d",F,I,N,M);

    I=pow((1+I/M),M)-1;

    P=F/pow((1+I),N);

    printf("\n输出本金结果:%.2lf\n",P);

}

 

void nianfen()

{

    double F,P,I,N;

    int M;

    system("cls");

    printf("\t欢迎进入投资年限计算软件\n");

    printf("请输入终值:");

    scanf("%lf",&F);

    printf("请输入年利率:");

    scanf("%lf",&I);

    printf("请输入本金:");

    scanf("%lf",&P);

    printf("请输入年复利次数:");

    scanf("%d",&M);

    printf("终值\t年利率\t本金\t年复利次数\n");

    printf("%.2lf\t%.2lf\t%.2lf\t%d",F,I,P,M);

    I=pow((1+I/M),M)-1;

    N=log(F/P)/log(1+I);

    printf("\n输出投资年限估计:%lf\n",N);

}

package fuli;

import java.sql.*;

public class mysql  {

    static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";

    static final String DB_URL = "jdbc:mysql://localhost/test";

    static final String USER = "root";

    static final String PASS = "root";

 

    int i=1;

    double output(String gongsi,String putinto,String earnings,String year,String money) throws SQLException{

        Connection conn = null;

        Statement stmt = null;

         

        //STEP 2: Register JDBC driver

        try {

            Class.forName(JDBC_DRIVER);

        } catch (ClassNotFoundException e) {

            // TODO Auto-generated catch block

            e.printStackTrace();

        }

        //STEP 3: Open a connection

        conn = DriverManager.getConnection(DB_URL,USER,PASS);

         

        //STEP 4: Execute a query

        stmt = conn.createStatement();

         

        String sql;

        sql = "SELECT * FROM touzi";

        ResultSet rs = stmt.executeQuery(sql);

         

        int r=1;

        double sum=0;

        //STEP 5: Extract data from result set

          while(null != rs && rs.next()){

             System.out.println(rs.getString("putinto"));

             System.out.println(rs.getString("earnings"));

             System.out.println(rs.getString("number"));

              

             System.out.println();

             r++;

             sum=Double.parseDouble(rs.getString("money"))+sum;

        }   

         

        String I = Integer.toString(i);

        String sql1 = "INSERT INTO touzi(number,gongsi,putinto,earnings,year,money) VALUES(";

        sql1=sql1+"'"+I+"'"+','+"'"+gongsi+"'"+','+"'"+putinto+"'"+','+"'"+earnings+"'"+','+"'"+year+"'"+','+"'"+money+"'"+')';

        

        i++;

        

        System.out.print(sql1);

        stmt.executeUpdate(sql1);

         

        rs.close();

        stmt.close();

        conn.close();

        return sum;

    }

     

 

 

void lilv()

{

    double F,P,I;

    int M,N;

    system("cls");

    printf("\t欢迎进入投资项目利率计算软件\n");

    printf("请输入终值:");

    scanf("%lf",&F);

    printf("请输入本金:");

    scanf("%lf",&P);

    printf("请输入存入年限:");

    scanf("%d",&N);

    printf("请输入年复利次数:");

    scanf("%d",&M);

    printf("终值\t本金\t存入年限\t年复利次数\n");

    printf("%.2lf\t%.2lf\t%d\t%d",F,P,N,M);

    I=pow(pow(F/P,1.0/N),1.0/M)*M-M;

    printf("\n输出投资项目利率:%lf\n",I);

}

void dingqi(){

    double F,P,I;

    int N;

    system("cls");

    printf("\t欢迎进入定期投资软件\n");

    printf("请输入年投入:");

    scanf("%lf",&P);

    printf("请输入年复合增长率:");

    scanf("%lf",&I);

    printf("请输入持续投入年数:");

    scanf("%d",&N);

    printf("年投入\t年复合增长率\t持续投入年数\t\n");

    printf("%.2lf\t%.2lf\t%d\t",P,I,N);

    F=P*(1+I)*pow((1+I),N-1)/I;

    printf("\n输出结果:%.2lf\n",F);

}

main()

{

    int i;

    printf("\t欢迎进入单复利计算软件3.0\n");

    printf("\n1.单利计算");

    printf("\n2.复利计算");

    printf("\n3.求本金");

    printf("\n4.求投资年限");

    printf("\n5.求投资项目利率估计");

    printf("\n6.定期投资");

    printf("\n请输出选择项:");

    scanf("%d",&i);

    switch(i)

    {

    case 1:

        danli();

        break;

    case 2:

        fuli();

        break;

    case 3:

        benjin();

        break;

    case 4:

        nianfen();

        break;

    case 5:

        lilv();

        break;

    case 6:

        dingqi();

        break;

    default:

        return 0;

    }

}

 

转载于:https://www.cnblogs.com/wenting/p/5393449.html

你可能感兴趣的文章
Android Studio快捷键每日一练(2)
查看>>
atoi函数实现
查看>>
文本文件和二进制文件
查看>>
WCF 实例 —— Android 短信助手 (WCF + Android)
查看>>
C# 读写opc ua服务器,浏览所有节点,读写节点,读历史数据,调用方法,订阅,批量订阅操作...
查看>>
springMVC学习
查看>>
PHP 处理JSON数据
查看>>
SQL Text Literals 文本
查看>>
封装几个有用的函数
查看>>
初识HTML
查看>>
删除目录软链接注意事项
查看>>
一次完整的HTTP事务是怎样一个过程
查看>>
Codeforces Round #440(Div.2)
查看>>
.Net Discovery 系列之一--string从入门到精通(上)
查看>>
c# 主机和网络字节序的转换 关于网络字节序和主机字节序的转换
查看>>
Silverlight 自定义控件的继承问题
查看>>
博客介绍
查看>>
30个高质量的免费jQuery滑块PSD文件
查看>>
卸载phonegap
查看>>
VMware安装Centos7
查看>>