This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I am a true novice in this field and feel like I spend most of my time debugging shit programs that I create. Is it even programming if you are not writing lines of code? Just curious, because I am getting my ass whipped on the simplest of programs. I believe it's because I got a terrible background in math, which I am working on. But yeah just wanted to vent. Any insight is always appreciated.
Edit: Thanks for all the replies homies. This was really unexpected, and very encouraging. I am learning Java in school and trying to learn python/spring on the side, for those who were curious. Stay safe and happy coding.
Edit 2: This is the code I am working on. I am trying to do a simple lottery output and cannot get the correct result. package lottery;
import java.util.Scanner;
public class Lottery {
public static void main(String[] args) {
// Generate a lottery
int lottery = 456;
// Prompt the user to enter a guess
Scanner input = new Scanner(System.in);
System.out.print("Enter your lottery pick (three digits): ");
int guess = input.nextInt();
// Get digits from lottery
int lotteryDigit1 = 4;
int lotteryDigit2 = 6;
int lotteryDigit3 = 6;
// Get digits from guess
int guessDigit1 = 4;
int guessDigit2 = 5;
int guessDigit3 = 6;
System.out.println("The lottery number is " lottery);
// Check the guess
if (guess == lottery)
System.out.println("Exact match: you win $10,000");
else if
((guessDigit1 == lotteryDigit2 && guessDigit2 == lotteryDigit1 && guessDigit3 == lotteryDigit3)
|| (guessDigit1 == lotteryDigit2
&& guessDigit1 == lotteryDigit3 && guessDigit3 == lotteryDigit1)
|| (guessDigit1 == lotteryDigit3
&& guessDigit2 == lotteryDigit1 && guessDigit3 == lotteryDigit2)
|| (guessDigit1 == lotteryDigit3
&& guessDigit2 == lotteryDigit2 && guessDigit3 == lotteryDigit1)
|| (guessDigit1 == lotteryDigit1
&& guessDigit2 == lotteryDigit3 && guessDigit3 == lotteryDigit2))
System.out.println("Match all digits: you win $3,000");
else
System.out.println("Sorry, no match");
}
}
Any hints/suggestions are welcome, hell even some snarky remarks as long as it helps me move forward.
Prof sent me the "correct" which was if (g1 == l1 && g3 == l2 && g2 == l3 ||
g2 == l1 && g1 == l2 && g3 == l3 ||
g2 == l1 && g3 == l2 && g1 == l3 ||
g3 == l1 && g1 == l2 && g2 == l3 ||
g3 == l1 && g2 == l2 && g1 == l3)
System.out.println("Match all digits: you win $3,000");
That didn't work either.
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/computersci...