如何将文本文件中的数字相乘? [英] How do I multiply numbers from a text file together ?

查看:116
本文介绍了如何将文本文件中的数字相乘?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试编写一个程序,通过扫描程序读取文本文件,在文本文件中,它有人名,他们销售的产品以及销售产品的数量,我需要程序来读取文本文件并将每个人的数字相乘并打印总数,我正在努力将数字乘以数字。我目前的代码是

I am currently trying to write a program which reads a text file through a Scanner and on the text file it has peoples names, products they sold and how much they sold products for, and I need the program to read the text file and multiply the numbers together for each person and print the total and I am struggling with how id multiply the numbers together. My current code is

Import java.util.Scanner;
/**
*
* @author Adam
*/
public class PractiseSplit {
    public static void main(String[] args) {
        Scanner Scan = new Scanner (NumberCount.class.getResourceAsStream("pay.txt
        //Scan.useDelimiter(" ^([A-Za-z]+)\\s([0-9]+)\\s([0-9]+)$ ");
        String [] Emma = Scan.split("A-Z
        
        System.out.println("Thes in the String are ");
        while (Scan.hasNext())
        {
            String temp = Scan.next();
            System.out.println(temp);
        }
    
    }
    
}



不确定我是否采取了最好的方式,但可以任何人给我示例代码或指出我哪里出错

谢谢


not sure if im going the best way about it but can anybody give me example code or point out where im going wrong
Thanks

推荐答案

);
String [] Emma = Scan.split(
AZ

System.out.println( 字符串中的内容为);
while (Scan.hasNext())
{
String temp = Scan.next();
System.out .println(temp);
}

}

}
"); String [] Emma = Scan.split("A-Z System.out.println("Thes in the String are "); while (Scan.hasNext()) { String temp = Scan.next(); System.out.println(temp); } } }



不确定我是否会去最好的方式,但任何人都可以给我示例代码或指出我出错的地方

谢谢


not sure if im going the best way about it but can anybody give me example code or point out where im going wrong
Thanks


这篇关于如何将文本文件中的数字相乘?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆