3120 Shares

What is wrong with this code and can I make it shorter?

What is wrong with this code and can I make it shorter? Topic: Write letter and print it
May 20, 2019 / By Danielle
Question: this code is suposed to convert letters into numbers like a=1 b=2 and not be case sencitive like a=1 A=1 PL ESE INCLUDE FULL WORKING CODE WITH ANSWER i also need to shorten what i have because it is realy long here is what I have so far [start] Asc(x$)II input x$ if x$>97 AND if x$<122 then print x$-32 if x$="A" then print "1" if x$="B" then print "2" if x$="C" then print "3" if x$="D" then print "4" if x$="E" then print "5" if x$="F" then print "6" if x$="G" then print "7" if x$="H" then print "8" if x$="I" then print "9" if x$="J" then print "10" if x$="K" then print "11" if x$="L" then print "12" if x$="M" then print "13" if x$="N" then print "14" if x$="O" then print "1
Best Answer

Best Answers: What is wrong with this code and can I make it shorter?

Bonnie Bonnie | 4 days ago
Help us out and tell us what it is doing. I wrote this in VB, you can convert it to the language you want ****** Const arr As String = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" Dim str As String = InputBox("What letter?") Dim int As Int16 = 1 For Each s As String In arr If s = str.ToUpper Then MsgBox(int) End If int += 1 Next ***** Dane
👍 176 | 👎 4
Did you like the answer? What is wrong with this code and can I make it shorter? Share with your friends

We found more questions related to the topic: Write letter and print it


Bonnie Originally Answered: How to make my essay shorter?
Take out detail but leave enough of it so that your facts and ideas/beliefs are still backed up. Double sentencing (writing the same thing twice but rewarding it) can also be taken out. Just take out things that are extra little facts that are great for going the extra mile but aren't 100% necessary here. Just list the key facts with minimal yet full ( yes, it's an oxymoron by can be done) detail.
Bonnie Originally Answered: How to make my essay shorter?
Put your essay away and get a good night's sleep. then tomorrow reread it as if your beloved baby sister wrote it. Look for over explaining, Look for redundant points, look for the verbose.(too many words) Think about how many adjectives you have. Like a dark angry stormy night blacker than black hiding all the stars...One can go on and on when you need to be frugal with your words. To be a good writer you need to be a good editor and a good re writer. Go through and mark the major points. What works and what just gets in the way. Drop some of the ones that may be just as interesting but don't move the story ahead. Think what an I trying to say and how can I say it with out just going on and on.
Bonnie Originally Answered: How to make my essay shorter?
try to take out words that you dont need like excessive words. take out sentences that you dont really need to back up what youre writing your school essay about. shorten the paragraphs and multi sentences by combinging them and cutting out the number of words:) (like summarizing)

Alannis Alannis
Most languages have some kind of function called ordinal, or ord. It transforms a character to its ascii value. And any language has a to_lower_string function (name is different for each language), which transforms a string to lower case. Find out the rest yourself.
👍 70 | 👎 0

Alannis Originally Answered: Can any one tell me what is wrong with my code?
I'm not sure you want to use a.length to check if the number in the array is even a.length simply means the length of the array, it only check how many elements are inside, the method cares less about the identity of each one. the reason you see a.length in the for loop is because it fills out the condition, for(starting place;condition;incremen t the for loop will continue to run until the condition is false. say array a is 5 elements long, a.length will find that out and in a for loop for(i=2;a.length;i++) this will start at the index 2, and implement whatever statement you write, until it reaches index 5, as the increment setting is ++ (add 1) I would use a for loop followed by if(a[i]%2==0) combined with a for loop, it will check each individual element in your array and check the if statement. tho I don't know the supposed outcome here is what I changed, simply what I said above, hope this helps even if the answer for my version is wrong. public class Main { public static void main(String[] args) { System.out.println(isDual(new int[]{1, 1, 1, 2, 2, 2, 3, 3})); System.out.println(isDual(new int[]{3, 3, 3, 3, 3, 3, 3, 3})); System.out.println(isDual(new int[]{1, 2, 2, 2, 3, 3})); System.out.println(isDual(new int[]{2})); System.out.println(isDual(new int[]{})); } static int isDual(int[] a) { int dual=0; int sum=0; for (int j = 0; j < a.length; j++) { if (a[j]% 2 == 0) { for (int i = 0; i < a.length - 3; i++) { if (a[i] + a[i + 1] == a[i + 2] + a[i + 3]) { sum++; } } } if (sum == a[j] / 2 - 1) { dual = 1; } } return dual; } } the output was 1 1 1 1 0 may be wrong, but I hope I lead you on the right path. too many for loops embedded in one another can lead to different outputs, I learned that the hard way. =D just tinker around before you try to change the loop placement
Alannis Originally Answered: Can any one tell me what is wrong with my code?
there is not any blunders. in basic terms you may write your code like this (it extremely is my way -only and beautiful in case you like): physique { historic past-colour:#d0e4fe; } h1 { colour:orange; text cloth-align:middle; } p { font-relatives:"circumstances New Roman"; font-length:20px; } /type

If you have your own answer to the question write letter and print it, then you can write your own version, using the form below for an extended answer.