0
How to solve a code coach problem by the way it is supposed to meet the outcome?
I need the hint to solve because I tried multiple times but every time it displays # (1-6)test Condition failed?
17 Respostas
+ 6
Your code need to pass all the five test cases. Don't get frustrated if you don't pass a test case just look carefully into your code if you're missing any constraint.
+ 3
Show us your try and we will try to help.
+ 2
Save code in playground, no need to be public.
Then come to this thread and in the lower right corner there is a circled + sign.
Select insert code.
Then in upper left select "MY CODE BITS" and find your code, should be first.
The press done in upper right corner.
Or just copy paste it in to a message, thou first variant is better.
+ 1
No good you linked only problem description.
+ 1
Firstly remove the print enter a sentence line. No need for that. I'll check the rest.
+ 1
I am not proficient in Java to begin with.
Your whole approach is wrong. You have to rethink it. You will see further down why.
I managed to jump-start your code which was giving errors from the begining. Wrong calling of method character.isLetter, I capitalized the C. After fixing that code was printing only "no case found" few times. Conversion from char to int is done either by using a method or C style char-'0'. Like you did was returning only ASCII code. And other small but consistent errors.
After fixing all
I input: I have 2 dollars, 10 cents and 15 rupee.
Output: I have two dollars, onezero cents and onefive rupee.
So see what is off? You need to convert 10 to ten and 15 should remain 15. That is why your approach char by char is not good.
Hint. Try to take input as string, split it by space in an array of strings and perform replace only on elements equal with 0 to 10.
PS: learn how to link a code to a post. It is easier to get help. Also use comments on your code.
+ 1
Here is your jump-started code.
Messy code messy fix.
https://code.sololearn.com/ckT9vt7oWMQl/?ref=app
+ 1
I see you have not solved any one yet, solve the popsicles on python with this code
msg = "give away" if popsicles% siblings == 0 else "eat them yourself"
print(msg)
Try solving it in other language(s) of your choice..
+ 1
You can solve the "No Numerals" code coach challenge in python with this code:
input = str(input())
if "10" in input:
input = input.replace("10", "ten")
if "1" in input:
input = input.replace("1", "one")
if "2" in input:
input = input.replace("2", "two")
if "3" in input:
input = input.replace("3", "three")
if "4" in input:
input = input.replace("4", "four")
if "5" in input:
input = input.replace("5", "five")
if "6" in input:
input = input.replace("6", "six")
if "7" in input:
input = input.replace("7", "seven")
if "8" in input:
input = input.replace("8", "eight")
if "9" in input:
input = input.replace("9", "nine")
if "0" in input:
input = input.replace("0", "zero")
print (input)
0
How to add code here ?
0
import java.lang.*;
import java.util.Scanner;
class Program
{
String a="";
char c;
String d="";
int dig=0;
int i=0;
void input()
{
Scanner in=new Scanner(System.in);
System.out.print("Enter any sentence=");
a=in.nextLine();
}
void check()
{ char c;
for(int x=0;x<a.length();x++)
{
c=a.charAt(x);
if(character.isLetter(c)==true)
d=d+c;
else{
i=(int)(c);
switching(i);}
}
System.out.println("d");
}
void switching(int dig)
{
switch (dig)
{
case 0:
System.out.print("zero");
break;
case 1:
System.out.print("one");
break;
case 2:
System.out.print("two");
break;
case 3:
System.out.print("three");
break;
case 4:
System.out.print("four");
break;
case 5:
System.out.print("five");
break ;
case 6:
System.out.print("six");
break ;
case 7:
System.out.print
0
System.out.print ("seven");
break ;
case 8:
System.out.print("eight");
break ;
case 9:
System.out.print("nine");
break ;
case 10:
System.out.print("ten");
break;
default:
System.out.print("no case match found");
}
}
public static void main(String []args){
Program ob=new Program();
ob.input();
ob.check();
}}
0
Added code , now where is the error to be corrected?
0
I suppose I need to use string buffer as string is an immutable in nature.
0
Done.
0
in bwt, try like this yourself....
if(Charecter. isLetter(c) ==true)
//print that char write here.. Not after loop..
But with d=d+c; and calling switching will cause first print number then letters..
The case 10 will never match with this...
Only one char you are reading, 10 contains, (2 chars)... So default executes.
If first char is 1, check immediate next char is 0 or not...
Remove default, not needed in this case...
If the input contains space, the you need to it as it is...
Edit:
Add this in else part after i=c-'0';
if(i==1 && a.charAt(x+1)=='0')
{ i=10;x++; }
For the below code given by @Mihai Apostol to match all cases...