473,511 Members | 17,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

in my code below i have a small error in the line(System.out.println("Your Zodiac si)

8 New Member
Expand|Select|Wrap|Line Numbers
  1. import java.util.*;
  2.  
  3. public class zodiac2 {
  4. public static void main(String[] args) {
  5. String sign="";
  6.  
  7.  
  8. int month, day,year;
  9.  
  10. Scanner c = new Scanner (System.in);
  11. System.out.println("Enter day(1-31): ");
  12. day = c.nextInt();
  13. System.out.println("Enter month(1-12): ");
  14. month = c.nextInt();
  15. System.out.println("Enter year: ");
  16. year = c.nextInt();
  17.  
  18. if((month == 1) && (day <= 20) || (month == 12) && (day >= 22)) {
  19. sign = "Capricorn";
  20. } else if((month == 1) || (month == 2) && (day <= 19)) {
  21. sign = "Aquarius";
  22. } else if((month == 2) || (month == 3) && (day <= 20)) {
  23. sign = "Pisces";
  24. } else if((month == 3) || (month == 4) && (day <= 19)) {
  25. sign = "Aries";
  26. } else if((month == 4) || (month == 5) && (day <= 21)) {
  27. sign = "Taurus";
  28. } else if((month == 5) || (month == 6) && (day <= 21)) {
  29. sign = "Gemini";
  30. } else if((month == 6) || (month == 7) && (day <= 23)) {
  31. sign = "Cancer";
  32. } else if((month == 7) || (month == 8) && (day <= 23)) {
  33. sign = "Leo";
  34. } else if((month == 8) || (month == 9) && (day <= 23)) {
  35. sign = "Virgo";
  36. } else if((month == 9) || (month == 10) && (day <= 23)) {
  37. sign = "Libra";
  38. } else if((month == 10) || (month == 11) && (day <= 22)) {
  39. sign = "Scorpio";
  40. } else if(month == 12) {
  41. sign = "Sagittarius";
  42. }
  43.  
  44. }
  45.  
  46.  
  47. System.out.println("Your Zodiac sign is "+sign+".");
  48.  
  49.  
  50. }
Oct 21 '13 #1
2 1235
yanalvine
8 New Member
hello i cant find where to correct it, can someone help
Oct 21 '13 #2
janculoo
1 New Member
Copy and paste your print line in the method body because right now it is outside of it. So it should look like this

Expand|Select|Wrap|Line Numbers
  1.     } else if(month == 12) {
  2.             sign = "Sagittarius";
  3.         }
  4.                 System.out.println("Your Zodiac sign is " + sign + ".");
  5.  
  6.     }
Oct 21 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2135
by: samlicon | last post by:
i have a java project to do , but what problem i encounter is how to fill / put an image of jpeg into a Reatangle in the code below please type the code in detail since i am an entry level...
67
4193
by: Steven T. Hatton | last post by:
Some people have suggested the desire for code completion and refined edit-time error detection are an indication of incompetence on the part of the programmer who wants such features. ...
14
3104
by: joshc | last post by:
I'm writing some C to be used in an embedded environment and the code needs to be optimized. I have a question about optimizing compilers in general. I'm using GCC for the workstation and Diab...
31
2590
by: DeltaOne | last post by:
#include<stdio.h> typedef struct test{ int i; int j; }test; main(){ test var; var.i=10; var.j=20;
16
1148
by: Daniel | last post by:
Hi Group, Why does the below code not generate an error? I have a table with x number of records. Each record is read from the DB into a hashtable. Then I add to the hashtable additional keys....
1
1369
by: John | last post by:
The following code has run-time error on "divide by 0" error. I expect "do the work<br>" will not print in the browser, since it happen after the code that cause the error. However, this is the...
6
1948
by: vbdog | last post by:
Hi I am trying to convert the vb6 code below into vb.net code can anyboddy help The vb6 code is from a chip8 Emulator that somboddy wrote. vb6 code this function keeps getting called until the...
8
2101
by: jd2007 | last post by:
Why the Ajax code below in ajax.js is causing my form not to work ? ajax.js: var a=0; var b=0; var c=0; var d=0; var e=0; var f=0;
4
1983
by: JimCarlson | last post by:
I have a form where the user selects the type of time off they wish to request. It is defined as follows: Control Source: Time Off Type (data type is Text and field size =1) Row Source Type: ...
0
2136
by: davidson1 | last post by:
Hi, I have ran the below code in java, but it is throwing an NoSuchField error. Can you please help me to correct this code? I have included all the required Jar files and pointed in Environment...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7427
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7085
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.