Just confused on how I would make this instruction given:
You are going to create an app to help you determine what percentage you should tip someone based on the quality of service you received.
You are to pick at least three (3) places to tip and create an app that will allow the user to enter the amount of their bill and the quality of service they received. There will be an output displaying the amount you should tip and the total amount of your bill and the tip.
With each place to tip, you are going to change an image to match that area, it can either be the entire background or just a portion of the screen
Need help fast!
ok I thought you run a startup company or something then you should tag âhomeworkâ too: FAQ - Processing Foundation
and as stated in the link, you canât ask for the âanswerâ. Do you have something you tried already? If not did they provide some code to start with? If you have completely no idea, I recommend to follow tutorials such as the coding train to how to get started.
right now i have added the basic format like looks for the app with a title and added some drop-down menus its just the actual calculating using percentages adding total amounts after the percentage is added having a final price of the bill too.
this is my current code right now im trying to use the drop down menu to change the background to the according restaurant in the drop down menu but keep getting errors please help:
var pickEvent;
var m, bp, n; // variables to hold my images
var img;
var day = âwhatâ;
var sel;
var sel1;
// preload some images
function preload() {
m = loadImage(âmandarin.jpgâ);
bp = loadImage(âbostonpizza.jpgâ);
n = loadImage(ânandos.jpgâ);
}
function setup() {
let inp = createInput(ââ);
inp.position(312, 175);
inp.size(100);
ok thatâs a good start - however I see you posting from email, but I recommend using the web platform and use </> button to format the code. Itâs hard to read it like this.
not exactly sure what the errors are they arenât very specific it just shows âscript errorâ but im guessing it might have to do with the âpicker. valueâ because itâs pointing at that line.
sorry I had to copy the url from your screenshot to try the code. when I run the âproductionâ link, I get error at image(img, 0, 0), which I guess, itâs because until pickEvent is fired, img remains empty so that it cannot draw anything.
by the way itâs a bit weird that repl.it shows âscript errorâ message. I wonder if theres a way to show proper error messageâŚ
yes basically img is not defined at first, so either
initialize img in setup by assiging one of the images
or skip image() if img is not defined
The latter is what Chrisir suggested, but strictly speaking, when a variable is not defined yet, it is undefined so you should test like img !== undefined