ChineseZodiac | Chinese Zodiac is an iOS app developed in Swift | iOS library
kandi X-RAY | ChineseZodiac Summary
kandi X-RAY | ChineseZodiac Summary
Chinese Zodiac is an iOS app developed in Swift. This app is used for an online video training course to teach the learners to build the first iOS app.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of ChineseZodiac
ChineseZodiac Key Features
ChineseZodiac Examples and Code Snippets
Community Discussions
Trending Discussions on ChineseZodiac
QUESTION
def chineseZodiac(year):
if (year - 2000) % 12 == 0:
sign = 'Dragon'
elif (year - 2000) % 12 == 1:
sign = 'Snake'
elif (year - 2000) % 12 == 2:
sign = 'Horse'
elif (year - 2000) % 12 == 3:
sign = 'sheep'
elif (year - 2000) % 12 == 4:
sign = 'Monkey'
elif (year - 2000) % 12 == 5:
sign = 'Rooster'
elif (year - 2000) % 12 == 6:
sign = 'Dog'
elif (year - 2000) % 12 == 7:
sign = 'Pig'
elif (year - 2000) % 12 == 8:
sign = 'Rat'
elif (year - 2000) % 12 == 9:
sign = 'Ox'
elif (year - 2000) % 12 == 10:
sign = 'Tiger'
else:
sign = 'Hare'
return sign
year = int(input("enter year:"))
while (year <= 1980 and year >= 2014):
print("your chinese zodiac is ", chineseZodiac(year))
...ANSWER
Answered 2022-Apr-02 at 00:32You input a value for year and then check if it is within the accepted timespan. ok. But if you do this with a while-loop, you will just reprint your output again and again for eternity.
Just use a one time if-statement like so:
QUESTION
using System;
namespace survey {
static class program {
static void Main(string[] args) {
program.chinesezodiac();
Console.WriteLine("\nYour name is: " + name);
Console.WriteLine("Your age is: " + age);
if (year == "1999") {
Console.WriteLine("You were born in the year of the rabbit");
}
else if (year == "2000") {
Console.WriteLine("You were born in the year of the dragon");
}
else if (year == "2001") {
Console.WriteLine("You were born in the year of the snake");
}
else if (year == "2002") {
Console.WriteLine("You were born in the year of the horse");
}
else if (year == "2003") {
Console.WriteLine("You were born in the year of the goat");
}
else if (year == "2004") {
Console.WriteLine("You were born in the year of the monkey");
}
else if (year == "2005") {
Console.WriteLine("You were born in the year of the rooster");
}
else if (year == "2006") {
Console.WriteLine("You were born in the year of the dog");
}
else if (year == "2007") {
Console.WriteLine("You were born in the year of the pig");
}
else if (year == "2008") {
Console.WriteLine("You were born in the year of the dragon");
}
else if (year == "2009") {
Console.WriteLine("You were born in the year of the ox");
}
else if (year == "2010") {
Console.WriteLine("You were born in the year of the tiger");
}
else {
Console.WriteLine("Invalid year");
}
}
public static void chinesezodiac(string[] args) {
Console.WriteLine("\nPlease note\nThis program is only applicable for users born between 1999 and 2010");
Console.WriteLine("\nPlease input name > ");
public static string name = Console.ReadLine();
if (name == "") {
do {
Console.Write("Invalid input. Please try again > ");
name = Console.ReadLine();
} while ( name == "");
}
Console.WriteLine("\nPlease input age > ");
public static string age = Console.ReadLine();
if (age == "") {
do {
Console.Write("Invalid input. Please try again > ");
age = Console.ReadLine();
} while ( age == "");
}
Console.WriteLine("\nPlease input birth year > ");
public static string year = Console.ReadLine();
if (year == "") {
do {
Console.Write("Invalid input. Please try again > ");
year = Console.ReadLine();
} while ( year == "");
}
}
}
}
...ANSWER
Answered 2020-Mar-08 at 07:23So instead of trying to set globally available values, what I would recommend would be to turn your name/age logic into functions you can call from Main() that return the values. For instance, you could turn your name logic into something like
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install ChineseZodiac
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page