Java job character variable integer add, integer output

Source: Internet
Author: User

receive multiple numeric summation outputs from the command line

First, design ideas

Enter two strings with the input statement, convert to Integer integer.parseint (string), add, and convert the result to the string string.valueof (int) output.

Second, the Process flow chart

Third, the source program code

Package demo;

import Java.util.Scanner;

Public class intandstring {

Public Static void Main (string[] args) {

Scanner i=New Scanner (System. in);

System. out. println ("Please input:");

String Str1=i.next ();

String Str2=i.next ();

int A=integer. parseint (STR1);

int B=integer. parseint (STR2);

int sum=0;

Sum=a+b;

String str3=string. valueOf (sum);

System. out. println (STR3);

    1. Close ();

}

}

Iv. Results of the procedure

Java job character variable integer add, integer output

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.