我正在编写我的第一个java程序,我终于把它全部写了但是在分配时我需要添加一个函数(除了main)。我的程序计算了名字中的字母数,所以我想也许我可以添加一个函数来读取多少字母是大写的?有什么想法吗?
public class NameLetters{
public static void main(String []args){
Scanner in = new Scanner(System.in);
String firstName; //Asks for the users first name
int count=0; //Count the letters passing through loop
System.out.print("Hello, this program will ask for your first name and then output the number of letters in your name.");
System.out.print("Please enter your first name:");
String firstName = input.NextLine();
for (int i=0; i<firstName.length(); i++) {
if (firstName.charAt(i) != ' ')
Count ++;
}
system.out.print("There are "+Count+" s in the first name "+firstName+" , Thank you for participating. Goodbye!");
}
}
答案 0 :(得分:-1)
public void getTemperature(org.w3c.dom.Document doc)
throws javax.xml.transform.TransformerException, javax.xml.xpath.XPathExpressionException
{
javax.xml.xpath.XPathFactory xpathFactory=javax.xml.xpath.XPathFactory.newInstance();
javax.xml.xpath.XPath xpath=xpathFactory.newXPath();
String temperature=(String)xpath.evaluate("product/time[contains(@from,'"+timeCheck+"')]/location/temperature/@value", doc, javax.xml.xpath.XPathConstants.STRING);
}