• Breaking News

    Friday, April 16, 2021

    C++ help with Class Ask Programming

    C++ help with Class Ask Programming


    C++ help with Class

    Posted: 16 Apr 2021 07:28 PM PDT

    Hello I am making a receipt using with Class on C++, the problem is my change is not computed correctly. Also, is there another better way for my code like where can I use functions? I'm not sure especially in the total, tax, and change part. Thanks! My code is below:

    #include <iostream>

    using namespace std;

    class Receipt

    {

    public:

    string itemName;

    int quantity;

    double itemPrice;

    double tax;

    double total;

    double change;

    double cash;

    double perItemCompute()

    {

    total = quantity * itemPrice;

    return total;

    }

    double taxCompute()

    {

    tax = total * 0.12;

    return tax;

    }

    double changeCompute()

    {

    change = cash - total;

    return change;

    }

    };

    int main() {

    Receipt r1, r2, r3;

    cinr1.itemNamer1.quantityr1.itemPricer1.cash;

    cinr2.itemNamer2.quantity>>r2.itemPrice;

    cinr3.itemNamer3.quantity>>r3.itemPrice;

    cout<<r1.itemName<<" x "<<r1.quantity<<endl;

    cout<<" @ "<<r1.itemPrice<<endl;

    cout<<r2.itemName<<" x "<<r2.quantity<<endl;

    cout<<" @ "<<r2.itemPrice<<endl;

    cout<<r3.itemName<<" x "<<r3.quantity<<endl;

    cout<<" @ "<<r3.itemPrice<<endl;

    cout<<"==============================="<<endl;

    double overallTotal = r1.perItemCompute() + r2.perItemCompute() + r3.perItemCompute();

    cout<<"TOTAL : "<<overallTotal<<endl;

    double overallTax = r1.taxCompute() + r2.taxCompute() + r3.taxCompute();

    cout<<"VAT (12%) : "<<overallTax<<endl;

    cout<<"CASH : "<<r1.cash<<endl;

    cout<<"CHANGE : "<<r1.changeCompute();

    }

    INPUT:

    Sardines 2 150 1000

    Fish_Stick 3 130

    Apple 1 45

    submitted by /u/Sure_Presentation_34
    [link] [comments]

    Is JDBC (Java) commonly used in industry?

    Posted: 16 Apr 2021 05:31 AM PDT

    At my company every team uses JDBC with raw SQL strings. My team uses jOOQ which imo is a lot more enjoyable to work with.

    I'm just curious if this is the norm and do most other companies predominantly use JDBC rather than jOOQ, Hibernate etc. or is it the other way round?

    submitted by /u/kcon1
    [link] [comments]

    I want to write a program in python that an end-user without programming experience can run. What is the fewest possible steps an end user would have to take to run a python program I write?

    Posted: 16 Apr 2021 09:08 PM PDT

    (Help) Connect to JawsDB with admin privileges

    Posted: 16 Apr 2021 09:02 PM PDT

    I'm currently using JawsDB as a database server for my web application that I've been building in netbeans using Java. My problem is, I keep running into an error that says I've exceeded the max number of user connections. I've checked my code thoroughly and as far as I can tell I'm closing all of my connections after use.

    I noticed when a query is run on the db server, the connection remains idle for a long period of time before terminating. This occurs even when I enter into the menu to create entity classes from database which is another reason why I don't think it has to do with my code.

    I need to either decrease the max idle/sleep time or increase the amount of user connections but these both require admin privileges.

    I'm connecting to the JawsDB using the parameters given in the DATABASE_URL and I was assuming this would be an admin account but apparently it isn't?

    Please if anyone can help, it would be greatly appreciated!!!

    EDIT: when I try to decrease idle time or increase user connections, I get an access denied error message.

    submitted by /u/kp4ws
    [link] [comments]

    Async/await troubles

    Posted: 16 Apr 2021 07:52 PM PDT

    Hello,

    I've got this firebase cloud function (node js):

    export const confirmAppointment = functions.https.onCall(async (data, context) => { const docId = data.id; delete data.id; let status = false; const confirmAppointment = await firestoreDB.collection('appointments').add(data) .then(() => { console.log("Appointment confirmed"); firestoreDB.collection('pendingAppointments').doc(docId).delete() .then(() => { console.log("Pending appointment removed."); status = true; }) .catch((error) => { console.error("Error deleting pending appointment: ", error); }) }) .catch((error) => { console.error("Error confirming appointment: ", error); }); confirmAppointment; return status; }); 

    And this front end function (angular):

     confirmAppointment(pendingAppointment){ const callable = this.fireFunctions.httpsCallable('confirmAppointment'); const confirmAppointment = callable(pendingAppointment).subscribe(data => { console.log(data); if (data) { this.toast.success("Appointment Confirmed"); this.fetchPendingAppointments(); this.fetchAppointments(); } else { this.toast.error("Failed to confirm Appointment. Please try again later.") } }); return confirmAppointment; } 

    For some reason status retuns as "false" every time, even when both add and delete actions are successful. The async cloud function is returning status before the code in the await function completes... can someone please help me understand why?

    Thank you very much for any help...

    submitted by /u/StedSix
    [link] [comments]

    Pi Pico microphone boom light idea

    Posted: 16 Apr 2021 04:06 PM PDT

    I have an idea for what I want to do with my Pi Pico & the Pico pim543 display but no idea how to execute the plan. I want to make my own boom mic live light.

    The idea is the LED/s will light up when the microphone (Default windows 10 mic) is unmuted within Windows 10. I would love to include some sort of visual use of the display board & it would be awesome if it can also use the buttons to mute/unmute the default microphone also BUT using the display board isn't the end of the world!

    If anyone can help / signpost me in the right direction to code this I would appreciate this ALOT!

    submitted by /u/Le_OpO
    [link] [comments]

    Question About MTG and Hashing

    Posted: 16 Apr 2021 10:09 AM PDT

    So this post is for people who are familiar with magic the gathering.

    As a sort of passion project I'm working on, I'm trying to build a platform for sorting and organizing a user's mtg physical card collection. in order to do that I want the user to connect a webcam to his computer and using computer vision technics the program would figure which cards are in the frame and then procced to save the identified card to a staging area for later sorting.

    My question is mainly about the card recognition, I have a very early working version of that, although it very very slow. My program is written in python and is using a phash implementation from the ImageHash library

    The pipeline is as follows:

    1. Grab a frame from the video and send it to a different thread for processing.
    2. Using cv2 look for contours that fits the card general dimensions and perspective transform it for top-down view (as if the card was viewed directly above it)
    3. Create a phash from the transformed card image.
      Note: I have already made a dataframe of all Mtg cards in history using scryfall's api and dumped it as a pickle
    4. This is the bad part. Iterate over all of Mtg cards in history and look for the closest phash match. this is roughly 50k entries.
    5. Repeat the process for each card in the frame.

    Note:
    Once a card is identified, it is saved and the next time a frame is grabbed the program will look for the identified cards from the previous frame. So only the first time a card is identified it take a long time (0.2 sec roughly).

    I'm looking for a way to make the process much faster then it is right now.
    What are your thoughts about it?

    Also, I am familiar with "classic" machine learning operations, less so with deep learning but I will manage if any one got an idea how to train a model.
    My first thought was to train a model for card color classification, the classes would be B/W/U/R/G/COLORLESS/MULTICOLOR/ELSE.
    ELSE would be just a fallback for a complete search in the 50k entries.

    Thanks for anyone for reading this and helping out! :)

    github repo
    Video example in the repo.

    submitted by /u/TheLooLzzz
    [link] [comments]

    GMBO algorithm doesn't seem to work, any help?

    Posted: 16 Apr 2021 01:25 PM PDT

    I'm trying to implement the gases brownian motion optimization algorithm to optimize the Schwefel function. I want to get my algo right for typical benchmarking problems, then scale up to other things.

    Here's my code. It can be run from a shell with ./file.py. The literature I'm referring to this, specifically section 3.

    According to the source document, it should be able to find the minimum of the function. I've followed the math correctly as far as I can tell, although I made a guess at initial temperature and boltzman constant. However, I find solutions don't tend to improve and in fact remain fairly large, far and away from the minimum.

    Any ideas?

    submitted by /u/setzRFD
    [link] [comments]

    Scaleable Card Picker

    Posted: 16 Apr 2021 12:55 PM PDT

    Let's say you have to simulate a certain number of cards each with a number on it from 1 to 52, and have to create a program to create a random sequence of cards. Okay, simple, pick a number randomly and put it in an array. Do that again, and if the number is already in the array, ignore it. However, what if you have to use millions or billions of cards. Then it takes up more and more memory, and more and more time. What you need is a random hashing algorithm that takes in a range of numbers 1-MAX and outputs a randomized set of numbers that is the same length and between 1 and MAX, with no numbers repeating. Are their any algorithms that produce random permutations of a range of numbers, mapping each number in the range, with another random number in that range, and has no hash collisions.

    submitted by /u/KlutzyDesign
    [link] [comments]

    Calendar booking script

    Posted: 16 Apr 2021 05:16 AM PDT

    How would I write code that will refresh a webpage, check if any calendar dates in April are free, then check for May. If any of those is green, I would get some sort of a audio notification. If not, refresh and try again.

    This is for my driving license reservation. I would appreciate any help as I don't know how to code, but I am willing to try to learn for this :).

    Photo reference: https://imgur.com/a/424otHz

    submitted by /u/Edgy_Teen69
    [link] [comments]

    Coding challenge website

    Posted: 16 Apr 2021 10:54 AM PDT

    Hi,

    So I've been searching for websites to improve my coding skills and way of thinking.

    I've Seen CodeWars, CodeChef, TopCoder, HackerRank and others, but I don't know if there's one better than another (every website says different)

    So is there one known to be good/giving good rankings ?

    submitted by /u/ThysGuy0
    [link] [comments]

    Im trying to deploy a discord bot on heroku

    Posted: 16 Apr 2021 10:53 AM PDT

    when every i deploy the bot im receiving this error

    [error] No matching files. Patterns tried: ./{src,src/plugins}/*.ts !**/node_modules/** !./node_modules/** !**/.{git,svn,hg}/** !./.{git,svn,hg}/**

    i have no clue where to go from here,

    submitted by /u/lilEpicNam3
    [link] [comments]

    What kind of security would a simple PHP/JS (no database/user input) site need ?

    Posted: 16 Apr 2021 06:55 AM PDT

    Hi, I'm an amateur programmer and I've created a simple ideas generator website in PHP/JS as a training project. There's no database or user input. The site works well and is basically done. However, I still need to make it secure before putting it online. My skills in cyber security are limited so I'm wondering if with this kind of website there really isn't much security needed (in which case I'd be able to do it myself with some advice) or if I should be looking for an experienced programmer who can review my code (knowing that my site is for non-commercial use and my budget is very limited) ? I would really appreciate any advice !

    (I'm crossposting this to r/CyberSecurityAdvice in case I need more specialized advices, hope that's ok)

    submitted by /u/JasminFlowerStar
    [link] [comments]

    Was there ever anything sophisticated about the engineering of 8chan?

    Posted: 16 Apr 2021 05:30 AM PDT

    I was watching Q: into the storm, the documentary about the origin of Qanon. One of several people profiled included Ron Watkins, a previous admin of 8chan who likely posted as Q for the majority of time. During one interview Ron says that while he can't do mental arithmetic he "understands very high level, PhD level math". He paints 8chan as some marvel of engineering thst he shepards. I immediately suspected this was a crock of shit and that on top of narcissism, he probably suffers from heaving dunning-kruger effect. But am I wrong? Was there anything special about the design of 8chan? Was there anything remarkable about the anonymous posting system?

    submitted by /u/radio555
    [link] [comments]

    Client paid $2k+ to integrate the Facebook SDK into his Android & iOS app. Did he get screwed on the price?

    Posted: 16 Apr 2021 08:56 AM PDT

    So my client just paid his "go-to developer" north of $2k to integrate the Facebook SDK in his Android (Kotlin) and iOS (Objective C) apps. We're just talking about the steps described here: https://developers.facebook.com/docs/app-events/getting-started-app-events-android

    I'm no developer, but charging 2k for a job like that seemed a little too high. Did my client get charged too much for this? How long does it usually take to integrate such an SDK? We're also looking into installing Firebase, Adjust and some other trackers, but I'm hesitant to contact the usual developer.

    (It's a relatively simple restaurant app)

    Appreciate your help!

    submitted by /u/whiskyncoke
    [link] [comments]

    Progressing with programming- what to do to go into a career?

    Posted: 16 Apr 2021 05:16 AM PDT

    I love programming and am currently in high school and taking a CS course. One problem I have though is that I love it at home and I do it so much that some of the programming stuff we do is sort of like a recap. However I really don't think that is necessarily good.

    I use LeetCode as well to progress my programming skills and test myself, however when I am using these resources I notice the stuff we learn at school is completely different to real like things. For example I hear lots of stuff about binary trees- and I have no clue what they are! Thats just one example. So my main question is, what resources should I be using, alongside school, that will help me with stuff I need in real life like coding interviews?

    submitted by /u/_leogaunt
    [link] [comments]

    tell me something

    Posted: 16 Apr 2021 04:23 AM PDT

    i am a programmer from India I just finished entire java course and i want to create something using code but i couldn't think of something so it would be awesome if you recommend something

    submitted by /u/adit_is_pro
    [link] [comments]

    No comments:

    Post a Comment