473,671 Members | 2,426 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 1237
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
2143
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 students thanks a lot the code Listed below
67
4249
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. Unfortunately these ad hominem rhetorts are frequently introduced into purely technical discussions on the feasibility of supporting such functionality in C++. That usually serves to divert the discussion from the technical subject to a discussion of the...
14
3132
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 compiler for the embedded target. My question is about how compilers optimize certain code sequences. As an example, take the code below. Will the compiler eliminate the actual function call to foo() in the object code generated and just store...
31
2611
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
1162
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. From here, i run through each key in the hashtable and change the associated value. Now, when I update the DB with the keys and values from the hashtable, all works well. However, I also added to the hashtable extra items. So, as far as I am...
1
1374
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 output: any ideas why?? Or this is the nature of ASP scripting language that is being executed in sequential order? Please advice. thanks!! //////// output /////////////////////////// before error
6
1956
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 image is drawn. Sub drawscreen() If Picture1.Point(1 + x + (i * 4), y + (j * 4)) = RGB(0, 255, 0) Then v(&HF) = 1 Picture1.Line (1 + x + (i * 4), y + (j * 4))-(1 + x + (i * 4) + 3, y + (j * 4) + 3), RGB(0, 0, 0),...
8
2117
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
1996
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: Value List Row Source: "V";"Vacation";"P";"Personal";"S";"Sick";"B";"Bereavement" Column Heads: No Column Count: 2 Bound Column: 1 The user selects the value from the drop list or types it in manually and when they try to tab to the next field...
0
2150
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 variable.I am using Java JDK 1.6.It successfully compiles but throws error while running. I am following the instructions to run this Java Code as given in the below link ...
0
8481
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8602
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7441
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6234
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5702
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2058
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.