Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6974935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:18:07+00:00 2026-05-27T17:18:07+00:00

I want to assign specific values to alphabets (below in the code) and then

  • 0

I want to assign specific values to alphabets (below in the code) and then calculate its
total added output which is provided by input string, which I am not getting. E.g. Kamran= 2+1+4+2+1+5 = 15 or abc = 1+2+3 = 6.
Via this code I only get the output of the last digit.
Thanks in Advance! Regards!!!

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class p1 {

    static int addition;
    static char Kamran;
    static int string1;
    static int total;
    final static int a=1,b=2,c=3,d=4,e=5,f=8,g=3,h=5,i=1,j=1,k=2,l=3,m=4,n=5,o=7,p=8,q=1,r=2,s=3,t=4,u=6,v=6,w=6,x=5,y=1,z=7;

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String userInput = in.readLine();
        for(int ai=0;ai<userInput.length();ai++){
            string1 = (int)userInput.charAt(ai);
        }
        int adder=0;

        if(string1=='k')
            {adder = 2 + adder ; }
        if(string1=='a')
            {adder = 1 + adder ; }
        if(string1=='m')
            {adder = 4 + adder ; }
        if(string1=='r')
            {adder = 2 + adder ; }
        if(string1=='b')
            {adder = 2 + adder ; }
        if(string1=='n')
            {adder = 5 + adder ; }

        total=adder;
        System.out.println(total);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:18:08+00:00Added an answer on May 27, 2026 at 5:18 pm
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    
    public class p1 {       
            final static int    a=1,b=2,c=3,d=4,e=5,f=8,g=3,h=5,i=1,j=1,k=2,l=3,m=4,n=5,o=7,p=8,q=1,r=2,s=3,t=4,u=6,v=6,w=6,x=5,y=1,z=7;
    
            public static void main(String[] args) throws IOException {
                BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
                String userInput = in.readLine();
                String input;
                int adder = 0;
                System.out.println(" userInput " + userInput);
                for (int i = 0; i < userInput.length(); i++){
                    input = userInput.charAt(i) + "";
                    System.out.println(" input " + input);
                    if (input.equals("k"))
                        adder += k; 
                    if (input.equals("a"))
                        adder += a;;
                    if (input.equals("m"))
                        adder += m;;
                    if (input.equals("r"))
                        adder += r;
                    if (input.equals("b"))
                        adder += b;
                    if (input.equals("n"))
                        adder += n;
                }                    
                System.out.println(" adder " + adder);  
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If I want to declare a vector of unknown size, then assign values to
I want to assign a specific menu in left sidebar block, based on the
I want create a role in SQL server 2008, which will allows specific group
I want to assign the decimal variable "trans" to the double variable "this.Opacity". decimal
I want to assign a resource I already have a second name, similar to
I want to assign a class attribute via a string object - but how?
I feel like a bonehead: I want to assign index=i to each LI I
Let's say I create an instance of a class and want to assign some
In my full text search query, I want to assign particular columns a higher
I am working on struts2. In my jsp page I want to assign the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.